Results 1 to 9 of 9

Thread: I can't connect signal QProcess::started() to a slot

  1. #1
    Join Date
    Aug 2009
    Posts
    11
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default I can't connect signal QProcess::started() to a slot

    Hi, I'm starting with QT, I try to connect a slot to signal QProcess::started() but can't. QObject::connect() returns false.
    Any idea what am I doing wrong?

    Here's part of the code:
    Qt Code:
    1. class foo : public QObject
    2. {
    3. public:
    4. QProcess *process;
    5.  
    6. public slots:
    7. void process_started();
    8. }
    9.  
    10. foo::foo()
    11. {
    12. process = new QProcess();
    13. bool status = QObject::connect( process, SIGNAL( started() ), this, SLOT( process_started() ) );
    14. // status is false, meaning the slot and signal couldn't be connected
    15. }
    To copy to clipboard, switch view to plain text mode 

    I know the process starts successfully because I tried process->WaitForStarted() and it returns true.
    But I put a breakpoint at the slot foo::process_started() and it never gets hit.
    What's the problem here?
    Thanks!

  2. #2
    Join Date
    Dec 2007
    Posts
    628
    Thanks
    3
    Thanked 89 Times in 87 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: I can't connect signal QProcess::started() to a slot

    Please write this Q_OBJECT macro in your class declaration. Like this.

    Qt Code:
    1. class foo : public QObject
    2. {
    3. Q_OBJECT
    4. public:
    5. QProcess *process;
    6.  
    7. public slots:
    8. void process_started();
    9. }
    10.  
    11. foo::foo()
    12. {
    13. process = new QProcess();
    14. bool status = connect( process, SIGNAL( started() ), this, SLOT( process_started() ) );// Removed QObject::
    15. // status is false, meaning the slot and signal couldn't be connected
    16. }
    To copy to clipboard, switch view to plain text mode 

  3. The following user says thank you to yogeshgokul for this useful post:

    Petruza (27th August 2009)

  4. #3
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: I can't connect signal QProcess::started() to a slot

    ...and rerun qmake & make.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  5. #4
    Join Date
    Aug 2009
    Posts
    11
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: I can't connect signal QProcess::started() to a slot

    Thanks Autobot, you're right!
    About qmake, I'll let QTcreator handle it
    Although QTcreator is pretty slow, don't you think?

  6. #5
    Join Date
    Dec 2007
    Posts
    628
    Thanks
    3
    Thanked 89 Times in 87 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: I can't connect signal QProcess::started() to a slot

    Quote Originally Posted by Petruza View Post
    Thanks Autobot
    !! VOILA !!

    Quote Originally Posted by Petruza View Post
    Although QTcreator is pretty slow, don't you think?
    If you compare it with VS then yes.

  7. #6
    Join Date
    Aug 2009
    Posts
    11
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: I can't connect signal QProcess::started() to a slot

    I hope it's not slow because it's built with QT
    In your experience, applications made with QT are slow? do they have other downside?

  8. #7
    Join Date
    Dec 2007
    Posts
    628
    Thanks
    3
    Thanked 89 Times in 87 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: I can't connect signal QProcess::started() to a slot

    Quote Originally Posted by Petruza View Post
    I hope it's not slow because it's built with QT
    Not at all. Its slow on windows because its compiler and debugger(=GDB) is slow. Creator can be used with MSVC on Windows, too – even for debugging.

    Quote Originally Posted by Petruza View Post
    In your experience, applications made with QT are slow? do they have other downside?
    No they are fast enough. Coz C++ is fast.

  9. #8
    Join Date
    Aug 2009
    Posts
    11
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: I can't connect signal QProcess::started() to a slot

    Quote Originally Posted by yogeshgokul View Post
    Creator can be used with MSVC on Windows, too – even for debugging.
    So I've read, I'll try it.
    There's a QT plugin for MSVC right?

  10. #9
    Join Date
    Dec 2007
    Posts
    628
    Thanks
    3
    Thanked 89 Times in 87 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: I can't connect signal QProcess::started() to a slot

    Yes.. !

Similar Threads

  1. pthread instead QThread
    By brevleq in forum Qt Programming
    Replies: 8
    Last Post: 23rd December 2008, 07:16
  2. Connection of custon signals/slots
    By brevleq in forum Qt Programming
    Replies: 2
    Last Post: 23rd December 2008, 07:04
  3. Connect signal from base to slot of sub-sub-object
    By donglebob in forum Qt Programming
    Replies: 15
    Last Post: 30th October 2008, 19:54
  4. Replies: 12
    Last Post: 18th September 2008, 15:04
  5. signal slot conection using a string, not a SLOT
    By rianquinn in forum Qt Programming
    Replies: 6
    Last Post: 5th February 2006, 18:52

Tags for this Thread

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.