Problem inserting in QTableWidget
Hi All,
I have a QTableWidget that I add rows during runtime using the following type of code:
Code:
bool QTClient
::addToTable (int id,
int lobby_view,
QString name
) {
int column = 0;
ui.m_TableWidget->insertRow(ui.m_TableWidget->rowCount ());
ui.m_TableWidget->setItem ( location_index, column++, tbl_item );
ui.m_TableWidget->setItem ( location_index, column++, tbl_item );
ui.m_TableWidget->setItem ( location_index, column++, tbl_item );
ui.m_holdemAllTableWidget->update ();
}
I have a button on my window that calls this code when pressed and the new line is added and displayed just fine in the table.
However, the problem comes when this add method is called from a thread.
When my thread fires it also calls the addTable method, but the data does not show up on the screen. The row count on the table increases, but the new data does not display.
Does anyone have any ideas why I can not see data added to my table from a thread?
Thanks in advance,
Derrick
Re: Problem inserting in QTableWidget
Quote:
Originally Posted by DPinLV
Does anyone have any ideas why I can not see data added to my table from a thread?
You can't invoke widget methods from a non-GUI thread (see here). To do it the right way, you have to turn addToTable() into a slot and use a queued connection.
Re: Problem inserting in QTableWidget
Jacek,
That explains a lot... I've been doing some more research and I'll be making another posting because my signal slot works using a simple type (i.e. int, QString, etc.), but the connect call fails when I pass my custom struct. :)
Thanks,
Derrick