I have a class like this
class GUI : public QWidget, public QThread
When I do the above i get errors about connect signals. The error says Reference to "connect" is ambiguous
. Is there a way to inherit from both?
Thank you
You can't. Both QWidget
and QThread
inherit (non-virtually) from QObject
. You therefore do not have virtual derivation, thus two copies of QObject
, which confuses the compiler. QObject
was specifically designed this way. See:
There are some who allegedly went around this (can't find the link right now, but it's out there on Google, I had the same trouble two weeks ago), but it is unsafe at best.
Edit: the best way would probably be to have another object inherit from QThread and keep that object as a member in your GUI
class. That is the sort of workaround most people do in this matter.