Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Hello. My Qt version is 4.8
I want enter by keyboard data to tableWidget and then read it.
How i can do it ?
I try to do the following.
QMessageBox msgBox; QTableWidgetItem* theItem = ui.tableWidget->item(i,j); QString theText = theItem->text(); msgBox.about(this,"Test",theText); }
it's not work.
if i use the commented code lines show me "Qt has caught an exception thrown from an event handler. Throwing exceptions from an event handler is not supported in Qt. You must reimplement QApplication::notify() and catch all exceptions there"
How to solve my problem ?
donjuedo last edited by
Have you tried single-step debugging to see which line is offending?
Hi and welcome to devnet,
Are you sure you have an item in each cell ?
I entered in each cell some digit value by hands for testing. It's the same error/exception
Jeroentjehome last edited by
When a QTableWidget is created all the cells are "empty". You need to add a widget to every cell to hold text/icons etc. The QTableWidget will be the parent of the items, so no cleanup is needed after it.
In your code this line
QTableWidgetItem* theItem = ui.tableWidget->item(i,j);
will probably return '0' pointer. So the next line to read the text will crash your program!
After generation of the table, add the items:
ui->tableWidget.setItem(i,j) = new QTableWidgetItem;
Hope this helps!
i create my table by Qt designer. So what do you mean by "After generation of the table" ?
Sorry i just started to learn Qt