July 5, 2011

insomnia insomnia
Lab Rat
1 posts

Connecting a signal to another thread’s slot


First of all im new to qt, so bare with me:)

Im wondering which way is the right way to do it.

I have a customized QWidget object and a QThread object & I need send SIGNALS between both;
Signals&slots that reside inside UI I found quite comfortable to connect as it has a nice graphical tool(Qt C++ Signal Slot Editor) to do it. But as i got to the part where i needed a thread i was unable to connect with signals&slots that reside outside of UI. It seems editor will only see objects defined in ui_xxx.h file which is generated by uic program from the xxx.ui file. So its useless to edit the ui_xxx.h file as the changes will be lost.

My question is:
1) is there a way connect signals/slots between QWidget and QThread with Qt C++ Signal Slot Editor?
2) if not what is the correct way to do it?

Oh and I am using eclipse qt plugin…

1 reply

July 5, 2011

peppe peppe
Ant Farmer
1005 posts

1) No. Use connect()s in your code :)
2) Don’t add slots to QThread subclasses. Avoid QThread subclassing if possible.


Software Engineer
KDAB (UK) Ltd., a KDAB Group company

  ‹‹ [SOLVED] QTableWidget stylesheet not working in QTabWidget      QMainWindow::setCentralWidget fails when using my custom QuadSplit widget ››

You must log in to post a reply. Not a member yet? Register here!