Results 1 to 3 of 3

Thread: Using QMetaObject::invokeMethod() doesn't work

  1. #1
    Join Date
    Jan 2007
    Posts
    91
    Thanks
    21
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Using QMetaObject::invokeMethod() doesn't work

    I'm trying to make my first QMetaObject::invokeMethod() call, but it doesn't work.

    Here is what I'm doing:


    Qt Code:
    1. int main(int argc, char *argv[])
    2. {
    3. QApplication app(argc, argv);
    4.  
    5. MainProcess *p = new MainProcess();
    6. p->slotStart();
    7. bool bValue = QMetaObject::invokeMethod(p, "slotStart", Qt::DirectConnection); // QueuedConnection);
    8.  
    9. return app.exec();
    10. }
    To copy to clipboard, switch view to plain text mode 

    The p->slotStart() calls the method just fine, but the invokeMethod() returns false.

    Any ideas?
    - BRC
    Last edited by wysota; 21st February 2007 at 21:35. Reason: missing [code] tags

  2. #2
    Join Date
    Jan 2006
    Posts
    128
    Thanked 28 Times in 27 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Using QMetaObject::invokeMethod() doesn't work

    Quote Originally Posted by bruccutler View Post
    Any ideas?
    Let's start with the simple ones:
    • slotStart is actually a slot?
    • MainProcess is a QObject?
    • MainProcess contains the Q_OBJECT macro?


    If you can answer all these questions with yes, we might have to digg deeper ;-)

  3. #3
    Join Date
    Jan 2007
    Posts
    91
    Thanks
    21
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: Using QMetaObject::invokeMethod() doesn't work

    No - slotStart was not a slot. I had forgotten to include Q_OBJECT in the header file. Oops - I've done that too many times when I create a new class.

    Thanks for your help.
    - BRC

Similar Threads

  1. QWidget -> updateGeometry dont work.
    By patrik08 in forum Qt Programming
    Replies: 7
    Last Post: 22nd May 2013, 15:55
  2. Replies: 3
    Last Post: 26th September 2006, 12:16
  3. work general with plugins
    By raphaelf in forum Installation and Deployment
    Replies: 14
    Last Post: 17th February 2006, 14:30
  4. QTextEdit Justify align making work
    By dec0ding in forum Qt Programming
    Replies: 2
    Last Post: 13th January 2006, 12:02

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.