[Qt-interest] Derive slots from non-Qt-based classes
Ian Thomson
Ian.Thomson at iongeo.com
Tue Apr 28 17:04:00 CEST 2009
Hi,
Please send replies to the list.
In the example code you posted, the Q_OBJECT macro is missing.
I think you should separate your display code and your processing code.
It sounds like it would be much easier if they were in different
hierarchies. Qt offers the signal/slot mechanism which makes this very
easy to do.
Cheers,
Ian.
Stefan Bisplinghoff wrote:
> Ian Thomson schrieb:
>> 1) You are missing the Q_OBJECT macro
>
> Q_OBJECT macro is only valid in QObject based classes.
>
>> 2) Is there a good reason you don't make the base class a QWidget?
>
> Yes, as stated before, my SomeDerivedClass inherits from SomeBaseClass
> *and* a QtClass. This could be a QWidget, but also a QGLWidget, so
> deriving SomeBaseClass from QWidget doesn't make much sense as the
> OpenGL functionality could not be integrated in that case.
>
> The key problem is that multiple inheritance of Qt-based classes is not
> allowed.
>
>> 3) Even better, why not make the base class a QObject which emits
>> signals which you can connect up to widgets to display the information.
>
> see above...
>
> Kind regards,
> Stefan
>
More information about the Qt-interest-old
mailing list