I've been trying to use QT4 with a QTableWidget to store data. I seem to be unable to select a cell and get the text out of it and wanted to see why it won't retrieve it.
ui->QTableWidget->item(ui->QTableWidget->rowCount(),0)->setText("");
QTableWidget uses indices which are zero based, so qTableWidget->rowCount()
is one past the end of your table.
To iterate over your items and see their text, you could do something like this:
// assuming #include <QtDebug>
for (int i=0; i<tableWidget->rowCount(); ++i)
{
qDebug() << tableWidget->item(i, 0)->text();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With