State machine transitions custom signals

  • In my program I have three classes. One that controls a QProcess(mplayer class) which I want to emit signals whenever certain sections of the code is hit. A wrapper class which sets the windows layout. And a window class which controls the state machine.To test this state machine i used a clicked signal from some pushbuttons (which worked fine), however when i now try to emit two custom signals it states:

    bq. QState::addTransition: no such signal QPushButton::mplayer::Running()

    bq. QState::addTransition: no such signal QPushButton::mplayer::Not_Running()

    The main section of the state machine in window class (top class) window.cpp
    @ Current_State = new QLabel;
    Current_State->setText("NO STATE");

    Not_Running = new QState();
    Initialised = new QState();
    Running = new QState();
    Not_Running->assignProperty(Current_State, "text", "Not_Running");
    Initialised->assignProperty(Current_State, "text", "Initialised");
    Running->assignProperty(Current_State, "text", "Running");
    //Not_Running->addTransition(button2, SIGNAL(clicked()),Initialised);
    Initialised->addTransition(mplayer, SIGNAL(mplayer::Running()),Running);
    Running->addTransition(mplayer, SIGNAL(mplayer::Not_Running()),Initialised);
    /* States are added in state machine */
    /*  Set the state initial for the state machine */
    /* Start the state machine */

    mplayer class which is the cpp file i want to emit signals from(bottom class) mplayer.cpp.
    @ this->m_process->setProgram(program);

        qDebug("\nSuccess in starting Process = Mplayer");
        emit Running();
        qDebug("\nFailed To start Process = Mplayer");


    qDebug("\nDeleting Process = Mplayer");
    emit Not_Running();

    @#ifndef MPLAYER_H
    #define MPLAYER_H

    #include <QWidget>
    #include <QProcess>

    class mplayer : public QWidget
    explicit mplayer(QWidget *parent = 0);

    void Running();
    void Not_Running();
    void Initialised();

    QString program = "C:\Users\Downloads\mplayer\mplayer.exe";
    QStringList arguments;
    QProcess *m_process;


    #endif // MPLAYER_H@

    If anyone has any ideas what im doing wrong please let me know thanks.

  • Just realised that in my transition I had button2 which I removed and replaced with mplayer (which just give me an error(error: expected primary-expression before ',' token). However will I need to make mplayer class a child of mplayer_wrapper and mplayer_wrapper a child of window ? is there any other way to reference mplayer class from window (as really they shouldn't be children as they have no real relationship to each other).

  • bq. I need to make mplayer class a child of mplayer_wrapper and mplayer_wrapper a child of window ? is there any other way to reference mplayer class from window

    How is the current relation of objects ? How are you accessing them ? If you give good details it will help us. Also this question is different from original post, it is good to put a new question with good details.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.