Results 1 to 2 of 2

Thread: How to emit signals from QRunnable?

  1. #1
    Join Date
    Jul 2010
    Posts
    11
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Question How to emit signals from QRunnable?

    How do you setup a QRunnable class so that it can emit signals?? Others on this forum say it is possible but nobody shows a good code snippet. If I try to use the following class definition, I get the compiler error:
    error LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __thiscall CMyTestClass::metaObject(void)const " (?metaObject@CMyTestClass@@UBEPBUQMetaObject@@XZ)
    1>threadtestapp.obj : error LNK2001: unresolved external symbol "public: virtual void * __thiscall CMyTestClass::qt_metacast(char const *)" (?qt_metacast@CMyTestClass@@UAEPAXPBD@Z)
    1>threadtestapp.obj : error LNK2001: unresolved external symbol "public: virtual int __thiscall CMyTestClass::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall@CMyTestClass@@UAEHW4Call@QMetaObject @@HPAPAX@Z)
    1>threadtestapp.obj : error LNK2019: unresolved external symbol "protected: void __thiscall CMyTestClass::fireEventNotification(class QString const &)"

    My class is defined as:

    class CMyTestClass : public QObject, public QRunnable
    {
    Q_OBJECT

    public:
    CMyTestClass(){}
    ~CMyTestClass(){}

    void run(){
    QString str = "sample";
    emit fireEventNotification(str);
    }
    void Initialize(const QString &str){}

    signals:
    void fireEventNotification(const QString &);

    };

    I want to have numerous threads running that will each throw signals back to the main app about status info. The main app slot handlers don't care which thread threw the signal it just displays the str message to a listview.

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: How to emit signals from QRunnable?

    That is a linker error related to the moc generated code. Re-run qmake and rebuild.

Similar Threads

  1. Define and emit signals
    By ruben.rodrigues in forum Newbie
    Replies: 2
    Last Post: 24th June 2010, 12:50
  2. "emit" keyword optional when calling signals?
    By will49 in forum Qt Programming
    Replies: 1
    Last Post: 21st November 2008, 01:13
  3. emit Signals
    By Fastman in forum Qt Programming
    Replies: 5
    Last Post: 22nd August 2007, 13:14
  4. QHttp and readyRead signals emit sequence
    By balitong in forum Qt Programming
    Replies: 4
    Last Post: 19th June 2006, 05:22
  5. Replies: 2
    Last Post: 6th January 2006, 21:15

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.