[Qt-interest] Multiple Inheritance Ambiguity question for QT4?

slayer81 at gmx.de slayer81 at gmx.de
Sun Oct 3 08:03:35 CEST 2010


Hello!

QThread inherits QObject, so you don't need to inherit both QObject and QThread in your class.
Just write "class hamlibWrapper : QThread" and you should be able to use Slots and Signals.

Greetings,
Paule


Am 03.10.2010 07:47:51, schrieb Rob Frohne <rob.frohne at wallawalla.edu>:

>Hi,
>
>I'm attempting to move some code I wrote for QT3 to QT4, and it appears 
>that I may have gotten away with something in QT3 that I should not be 
>doing. I think my problem is that I am trying to inherit from QObject so 
>I can use my own signals & slots, and also from QThread, which itself 
>inherits from QObject, leading to an ambiguity. Here is my header file:
>
>class hamlibWrapper : public QObject, QThread
>{
>Q_OBJECT
>public:
>hamlibWrapper ( QWidget *parent=0, const char *name=0 );
>~hamlibWrapper();
>int init ( rig_model_t, const char* port, int speed );
>void run();
>void setPause ( bool p );
>
>public slots:
>void setMode ( rmode_t, pbwidth_t );
>void pollSlopeTuning ( bool );
>void useMuteXmit ( bool );
>
>private:
>RIG* rRig;
>double freq, getfreq;
>bool shouldexit;
>ptt_t transmit;
>bool setmodes;
>QMutex mutex;
>freq_t getHardwareFrequency();
>rmode_t mode;
>rmode_t newMode;
>pbwidth_t width;
>pbwidth_t newWidth;
>value_t slopeLowVal;
>int slopeLow;
>value_t slopeHighVal;
>int slopeHigh;
>vfo_t vfo;
>bool useSlopeTuning;
>bool muteOnXmit;
>
>signals: // Signals
>void newFreq ( double );
>void nowTransmit ( int );
>void rigChangedMode ( rmode_t, bool );
>void slopeLowChangedByRig ( int );
>void slopeHighChangedByRig ( int );
>void rigPitch ( int );
>};
>
>and the warning I get is:
>
>/home/frohro/Projects/sdr-for-if-qt4/qtmerge/hamlibwrapper.h:35: 
>warning: direct base ‘QObject’ inaccessible in ‘hamlibWrapper’ due to 
>ambiguity
>
>Later I get errors resulting from this ambiguity:
>
>/home/frohro/Projects/sdr-for-if-qt4/qtmerge/hamlibwrapper.cpp:31: 
>error: reference to ‘connect’ is ambiguous
>
>from the connect lines of this code:
>
>
>#include <string.h>
>#include <stdlib.h>
>#include <qapplication.h>
>#include <math.h>
>
>#include "hamlibwrapper.h"
>
>hamlibWrapper::hamlibWrapper ( QWidget *parent, const char *name ) : 
>QObject ( parent, name )
>{
>rRig=NULL;
>shouldexit = FALSE;
>useSlopeTuning = FALSE;
>rig_set_debug ( RIG_DEBUG_TRACE ); // RIG_DEBUG_NONE for none.
>connect ( parent, SIGNAL ( changeRigMode ( rmode_t, pbwidth_t ) ), this, 
>SLOT ( setMode ( rmode_t, pbwidth_t ) ) );
>connect ( parent, SIGNAL ( changeSlopeTune ( bool ) ), this, SLOT ( 
>pollSlopeTuning ( bool ) ) );
>connect ( parent, SIGNAL ( tellMuteXmit ( bool ) ), this, SLOT ( 
>useMuteXmit ( bool ) ) );
>}
>
>This code worked fine in QT3, but not in QT4. Can anyone give me some 
>advice?
>
>Thanks,
>
>Rob
>
>-- 
>Rob Frohne, Ph.D., P.E.
>E.F. Cross School of Engineering
>Walla Walla University
>100 SW 4th Street
>College Place, WA 99324
>(509) 527-2075			 http://people.wallawalla.edu/~rob.frohne
>
>






More information about the Qt-interest-old mailing list