There's no real reason for CComListener to be a QObject if it is just an abstract interface. The public functions in the interface class can be treated as slots in the derived class For example, this seems to work:
Qt Code:
  1. #include <QtGui>
  2. #include <QDebug>
  3.  
  4. // Class is abstract by virtue of having at least one pure virtual
  5. class IComLineObserver
  6. {
  7. public:
  8. explicit IComLineObserver() {}
  9. virtual ~IComLineObserver() = 0;
  10.  
  11. // these can be slots in derived classes
  12. virtual void OnTxLine( QString sLine ) {}
  13. virtual void OnRxLine( QString sLine ) {}
  14. virtual void OnRxChar( QString sLine ) {}
  15. virtual void test() {}
  16. };
  17. IComLineObserver::~IComLineObserver() {}; // must have an implementation
  18.  
  19. class A: public QObject, public IComLineObserver
  20. {
  21. Q_OBJECT
  22. public:
  23. A() { }
  24. ~A() { }
  25. public slots:
  26. void test() { qDebug() << "Test"; }
  27. };
  28.  
  29. int main(int argc, char *argv[])
  30. {
  31. QApplication app(argc, argv);
  32.  
  33. A a;
  34. QTimer t;
  35. QObject::connect(&t, SIGNAL(timeout()), &a, SLOT(test()));
  36. t.start(1000);
  37. return app.exec();
  38. }
  39. #include "main.moc"
To copy to clipboard, switch view to plain text mode