marcvanriet
4th October 2010, 00:13
Hi,
I'm writing some classes to handle text that is transmitted over a serial communication link. There will be classes to 'observe' what is passing over the link. They are like textedits or linedits that show the data as it is received. Other classes will do logging etc.
I defined a base class for the observers with the necessary slots for receiving data. Then I derived a QUI object from this, based on a QPlainTextEdit. Like this :
class CComLineObserver : public QObject
{
Q_OBJECT
public:
explicit CComLineObserver(QObject *parent = 0);
public slots:
virtual void OnTxLine( QString sLine );
virtual void OnRxLine( QString sLine );
virtual void OnRxChar( QString sLine );
};
class CComLineTextEdit : public QPlainTextEdit, virtual public CComLineObserver
{
Q_OBJECT
public:
explicit CComLineTextEdit( QWidget * parent = 0 );
public slots:
virtual void OnRxLine( QString sLine );
};
When I use this CComLineTextEdit in a form, I get the following error message in setupUI of the UI_....H file that moc builds (teLog is the name of the gui object) :
ambiguous acces of 'setObjectName'
teLog->setObjectName(QString::fromUtf8("teLog"));
I think it has to do with the fact that both QPlainTextEdit and CComLineTextEdit are derived from QObject (the 'diamond problem'). I already used the 'virtual' keyword before 'CComLineTextEdit', but this doesn't help. I'm sure it's just a little syntax problem, but I just can't put my finger on it.
Does anyone know the solution ?
Thanks,
Marc
I'm writing some classes to handle text that is transmitted over a serial communication link. There will be classes to 'observe' what is passing over the link. They are like textedits or linedits that show the data as it is received. Other classes will do logging etc.
I defined a base class for the observers with the necessary slots for receiving data. Then I derived a QUI object from this, based on a QPlainTextEdit. Like this :
class CComLineObserver : public QObject
{
Q_OBJECT
public:
explicit CComLineObserver(QObject *parent = 0);
public slots:
virtual void OnTxLine( QString sLine );
virtual void OnRxLine( QString sLine );
virtual void OnRxChar( QString sLine );
};
class CComLineTextEdit : public QPlainTextEdit, virtual public CComLineObserver
{
Q_OBJECT
public:
explicit CComLineTextEdit( QWidget * parent = 0 );
public slots:
virtual void OnRxLine( QString sLine );
};
When I use this CComLineTextEdit in a form, I get the following error message in setupUI of the UI_....H file that moc builds (teLog is the name of the gui object) :
ambiguous acces of 'setObjectName'
teLog->setObjectName(QString::fromUtf8("teLog"));
I think it has to do with the fact that both QPlainTextEdit and CComLineTextEdit are derived from QObject (the 'diamond problem'). I already used the 'virtual' keyword before 'CComLineTextEdit', but this doesn't help. I'm sure it's just a little syntax problem, but I just can't put my finger on it.
Does anyone know the solution ?
Thanks,
Marc