How can i get in the QTableWidget the value from selected row and column?
-
The question is if you know already the row and column upfront?
If yes, there is no need of using the signal slot mechanism, since you know already which element you like to access.
You should use item method
If you want to click on an item and know which one this is, cellActivated or cellClicked signals may be a choice. -
If you want to get the values of selected items, you can use selectedItems() API and get the QListWidgetItem list. From this list you can fetch QListWidgetItem one-by-one and get QListWidgetItem.
QList<QTableWidgetItem *> list = selectedItems();
for(each i item in list) {
QTableWidgetItem *item = list.at(i)
qDebug() << item.text()
} -
The question is if you know already the row and column upfront?
If yes, there is no need of using the signal slot mechanism, since you know already which element you like to access.
You should use item method
If you want to click on an item and know which one this is, cellActivated or cellClicked signals may be a choice. -
Simple Example:
QString SelectedRow;
int col = 0;//Column
int row = 0;//Selected Row
SelectedRow = ui->MYQTableViewWidget->selectedItems().at(row)->data(col).toString();Change col for getting other Columns data.
Change row for getting other selected Rows data.