How to add selected items from table widget into a queue?
-
@suslucoder said in How to add selected items from table widget into a queue?:
If i understand how can i get selected items, it will be easy to add them on a queue
ui->tableWidget->selectedItems();You can get the selected items with this function. So use it.
-
@suslucoder said in How to add selected items from table widget into a queue?:
I want to get exact values which is on my table.
And what is the problem?
You can store pointers in a queue, or simply de-reference the pointers when adding them to the queue (C++ basics: *pointer). -
Hi
how can i get the exact values which i selected from table?
You mean its texts ?
QList<QTableWidgetItem*> MySelList = m_ui->tableWidget->selectedItems(); for (QTableWidgetItem* item : MySelList) { QString TheText = item->text(); // do stuff with text. }
-
I want to achieve somethings like this
ui->tableWidget->item(row,2)->text().toDouble();
Im using the 2th column's value, so when i select more tha one item, it should return me to last columns value
-
@suslucoder said in How to add selected items from table widget into a queue?:
so when i select more tha one item
I don't understand: you want to get selected items, what ever user selected, right? What should happen if user does not select anything in column 2? Can you please explain better what you're trying to achieve?
-
@suslucoder Do you mean user can only select items in column 2? If it is like this then there is no problem at all, simply use code @mrjj provided. All maybe I still don't understand you.
-
@suslucoder Actually, you can check from which column an item is coming: https://doc.qt.io/qt-5/qtablewidgetitem.html#column
So, use it and only add items from column 2...