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
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can’t. Both
QWidgetandQThreadinherit (non-virtually) fromQObject. You therefore do not have virtual derivation, thus two copies ofQObject, which confuses the compiler.QObjectwas 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
GUIclass. That is the sort of workaround most people do in this matter.