Hi ProTonS!
if there is no item on the location specified, the item function will return 0.
Just test the return value to see if it's a valid item or not.
item1 = ui.mywidget_table->item(0,1);
if(item1!=0)
{
helper = item1->text();
}
QTableWidgetItem *item1;
QString helper;
item1 = ui.mywidget_table->item(0,1);
if(item1!=0)
{
helper = item1->text();
}
To copy to clipboard, switch view to plain text mode
or check that the item exist before calling the item function.
if( ui.mywidget_table->rowCount() > 0 && ui.mywidget_table->columnCount() > 1)
{
item1 = ui.mywidget_table->item(0,1);
helper = item1->text();
}
QString helper;
if( ui.mywidget_table->rowCount() > 0 && ui.mywidget_table->columnCount() > 1)
{
QTableWidgetItem *item1;
item1 = ui.mywidget_table->item(0,1);
helper = item1->text();
}
To copy to clipboard, switch view to plain text mode
Bookmarks