Results 1 to 11 of 11

Thread: QStateMachine, not getting entered()

  1. #1
    Join Date
    Sep 2009
    Location
    UK
    Posts
    15
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows Symbian S60

    Default QStateMachine, not getting entered()

    Hi,

    I have set up a QStateMachine but I am not getting an entered() signal from any of the states and Creator editor is not even showing this in the class list as I type it in the connect function. I only get destroyed, polished and finished in the list. function code below.

    What am I doing wrong? ....any suggestions.

    Many thanks

    Jim

    Qt Code:
    1. connectionMachine = new QStateMachine(this);
    2. disconnected_SM = new QState();
    3. connecting_SM = new QState();
    4. connected_SM = new QState();
    5. statusCheck_SM = new QState();
    6. commsReady_SM = new QState();
    7.  
    8. disconnected_SM->addTransition(this, SIGNAL(connectToHost_SM()), connecting_SM);
    9. connecting_SM->addTransition(&commandSequencer, SIGNAL(connected()), connected_SM);
    10. connected_SM->addTransition(this, SIGNAL(updatingStatus_SM()), statusCheck_SM);
    11.  
    12. connectionMachine->addState(disconnected_SM);
    13. connectionMachine->addState(connecting_SM);
    14. connectionMachine->addState(connected_SM);
    15. connectionMachine->addState(statusCheck_SM);
    16.  
    17. connect(connecting_SM, SIGNAL(entered()), this, SLOT(debugConnecting()));
    18. connect(connected_SM, SIGNAL(entered()), this, SLOT(updateStatus()));
    19.  
    20. connectionMachine->setInitialState(disconnected_SM);
    21. connectionMachine->start();
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QStateMachine, not getting entered()

    Does connectToHost_SM() signal get emitted? Also check your console logs to see if there are any warnings from Qt.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Sep 2009
    Location
    UK
    Posts
    15
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows Symbian S60

    Default Re: QStateMachine, not getting entered()

    Hi wysota,

    I put in a connect() for the connectToHost_SM to output under qDebug and that works so it seems as though it is emitted. The logs at runtime and compile time don't show any warnigns or errors.

    Jim

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QStateMachine, not getting entered()

    connect() means it is connected, not that it is emitted.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Sep 2009
    Location
    UK
    Posts
    15
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows Symbian S60

    Default Re: QStateMachine, not getting entered()

    No, no....what I mean is that I put in

    Qt Code:
    1. connect(this, SIGNAL(connectToHost_SM()), this, SLOT(debugConnectToHost_SM()));
    To copy to clipboard, switch view to plain text mode 

    in order to see if connectToHost_SM() is emitted and debugConnectToHost_SM() just outputs a qDebug message so I can see that at runtime connectToHost_SM() is emitted.

    jim

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QStateMachine, not getting entered()

    Please provide a minimal compilable example reproducing the problem. The code you pasted looks correct so the problem is probably elsewhere. Try isolating it from the rest of your code.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #7
    Join Date
    Sep 2009
    Location
    UK
    Posts
    15
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows Symbian S60

    Default Re: QStateMachine, not getting entered()

    I haven't got round to getting a compiled version to post but I have noticed that the state machine does start. I have put a qDebug line after the .start() to check if the state machine is running but it comes back as not running!!!! any suggestions?

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QStateMachine, not getting entered()

    It's an asynchronous call. The machine will start next time Qt enters the event loop.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  9. The following user says thank you to wysota for this useful post:

    jimiq (19th November 2009)

  10. #9
    Join Date
    Sep 2009
    Location
    UK
    Posts
    15
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows Symbian S60

    Default Re: QStateMachine, not getting entered()

    I have no other events running at that time.
    I checked if it was running later in the app and it still comes back with stopped

  11. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QStateMachine, not getting entered()

    As already said, provide a minimal compilable example reproducing the problem. I can't help you without knowing what you did.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  12. #11
    Join Date
    Sep 2009
    Location
    UK
    Posts
    15
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows Symbian S60

    Default Re: QStateMachine, not getting entered()

    I managed to find the problem. When you mentioned about it being an asynchronous call got me thinking. I found that I was calling the state machine in the constructor of my dialog and was trying to trigger it too early. I then added a slot/signal combination to wait for the started() signal from the state machine before trying to create the TCP socket and now all appears fine.

    Thanks for your help.
    Jim

Similar Threads

  1. Replies: 28
    Last Post: 7th May 2010, 12:29
  2. QStateMachine
    By piotr.dobrogost in forum Qt Programming
    Replies: 3
    Last Post: 6th December 2009, 08:17
  3. QStateMachine and signals
    By rossm in forum Qt Programming
    Replies: 2
    Last Post: 26th March 2009, 10:43
  4. fetching each char entered in Qtextedit??
    By Shuchi Agrawal in forum Newbie
    Replies: 3
    Last Post: 17th February 2007, 11:07
  5. Record update windowd entered data saving
    By MarkoSan in forum Qt Programming
    Replies: 56
    Last Post: 18th January 2006, 18:50

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.