mohitkumarlal
mohitkumarlal

Reputation: 1

How can we make QTableWidget accessible from multiple threads and placing QPushButtons in a cell from another thread.?

I am new in Qt.I have a QTableWidget which is suppose to get continuous data from different threads of RTI DDS subscriber.I was using setUpdatesEnabled() property of the QTableview for updating values from another class.

But it also blocks the QTableWidget for in-between operations like selecting another row and whenever i try to add QPushButton in a certain column of QTableWidget with the help of setCellWidget(),it is making a separate PushButton instead of placing it inside that cell.

Upvotes: 0

Views: 402

Answers (1)

jpo38
jpo38

Reputation: 21564

As commented, you should do no GUI update from anywhere but the main thread. So use a signal/slot connection to go back from a worker thread to the main thread and then do the GUI update (emit the signal from the worker thread and make sure the slot is being executed from the main thread, this should behave like this with default connection). Be careful to the lifetime of the variables passed to the emited signal if slot is executed through a Qt::QueuedConnection.

Then, for your QPushButton not being in the cell. Make sure its parent is the QTableWidget upon creation (but I doubt this is really mandatory because I expect QTableWidget will make itself parent of the widget when setCellWidget is called).

It's hard to hep more with no code being posted in the OP.

Upvotes: 1

Related Questions