[SOLVED] live update to qtablewidget not working
hi, i'm trying to do live update of data to table for every 2 second delay. here is my code
QTableWidget *table=new QTableWidget(this);
qDebug()<<" sleep for 2s ";
qdebug prints data for every 2 second delay but in qtablewidget ,data is not getting updated for every 2 second. table gets filled at a time after "for " loop ends.
can anyone please tel me how to achieve this.
Any loop or blocking call (like sleep) in the main thread will prevent the GUI from updating itself.
You could use a QTimer and a slot instead of a loop.
alexisdm:: i tried using qtimer in slot function i need to update the qtablewidget continously with some delay but by using qtimer i can not see the table getting update.
Without seeing the new code, I can't know what you might have done wrong.
But basically, you should have something like:
@table = new QTableWidget(this);
count = 5;
timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), SLOT(updateSlot()));
int row = table->rowCount();
table->setItem(row, 0, new QTableWidgetItem("hello"));
table, count and timer should all be members of the class so that they can be accessed in the slot.
thanks alexisdm its working.