Results 1 to 2 of 2

Thread: QStateMachine doesn't starts :(

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Oct 2011
    Posts
    9
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Unhappy QStateMachine doesn't starts :(

    Hello Guys

    i have a problem with the QStateMachine. I want to use it for seting static positions for some GraphicsObjects, but it doesn't start

    here is my code for init the machine and states:

    Qt Code:
    1. void BedienelementController::initMachine()
    2. {
    3. _machine = new QStateMachine(this);
    4. initState();
    5. }
    6.  
    7.  
    8. void BedienelementController::initState()
    9. {
    10. _stateList.append(new QState());
    11. _stateList.append(new QState());
    12. _stateList.append(new QState());
    13.  
    14.  
    15. _stateList.at(0)->addTransition(this, SIGNAL(jsRechts()), _stateList.at(1));
    16. _stateList.at(1)->addTransition(this, SIGNAL(jsRechts()), _stateList.at(2));
    17. _stateList.at(2)->addTransition(this, SIGNAL(jsRechts()), _stateList.at(0));
    18.  
    19. _machine->addState(_stateList.at(0));
    20. _machine->addState(_stateList.at(1));
    21. _machine->addState(_stateList.at(2));
    22.  
    23. _machine->setInitialState(_stateList.at(0));
    24.  
    25. _machine->start();
    26.  
    27.  
    28. _stateList.at(0)->assignProperty(_textFelderH.at(0), "pos", *_punkteListe.at(0));
    29. _stateList.at(0)->assignProperty(_textFelderH.at(1), "pos", *_punkteListe.at(1));
    30. _stateList.at(0)->assignProperty(_textFelderH.at(2), "pos", *_punkteListe.at(2));
    31.  
    32. _stateList.at(1)->assignProperty(_textFelderH.at(0), "pos", *_punkteListe.at(1));
    33. _stateList.at(1)->assignProperty(_textFelderH.at(1), "pos", *_punkteListe.at(2));
    34. _stateList.at(1)->assignProperty(_textFelderH.at(2), "pos", *_punkteListe.at(0));
    35.  
    36. _stateList.at(2)->assignProperty(_textFelderH.at(0), "pos", *_punkteListe.at(2));
    37. _stateList.at(2)->assignProperty(_textFelderH.at(1), "pos", *_punkteListe.at(0));
    38. _stateList.at(2)->assignProperty(_textFelderH.at(2), "pos", *_punkteListe.at(1));
    39. qDebug() << _machine->isRunning();
    40.  
    41. }
    To copy to clipboard, switch view to plain text mode 

    The Debug output allways says "false".

    _stateList is a QList<QState*>, _punkteListe a QList<QPointF*> and _textFelderH ar my class inherited from QGraphicsObject
    The "BedienelementController"-Class is inherited from QWidget.

    i hope smbdy can give me a hint


    EDIT:
    okay... i have to read the online documentation... the statemachine can only be started when a event-loop is running...
    sry

    Thanks!

    with best regards

    nudels
    Last edited by nudels; 17th January 2012 at 22:08.

Similar Threads

  1. Start application when OS starts
    By sophister in forum Qt Programming
    Replies: 16
    Last Post: 13th April 2011, 07:38
  2. Segmentation Fault when Program Starts
    By KaptainKarl in forum Newbie
    Replies: 7
    Last Post: 10th September 2009, 09:43
  3. QProgressBar starts at random position
    By kodiak in forum Qt Programming
    Replies: 0
    Last Post: 8th September 2008, 11:59
  4. Selecting screen on the application starts
    By ^NyAw^ in forum Qt Programming
    Replies: 6
    Last Post: 12th March 2008, 00:20
  5. How to check if a string starts with a substring?
    By lni in forum Qt Programming
    Replies: 3
    Last Post: 18th April 2007, 01:36

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.