State machine transitions custom signals
-
wrote on 14 Aug 2014, 09:05 last edited by
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");
Current_State->resize(50,50);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 */ //machine.addState(Not_Running); machine.addState(Initialised); machine.addState(Running); /* Set the state initial for the state machine */ machine.setInitialState(Initialised); /* Start the state machine */ machine.start();@
mplayer class which is the cpp file i want to emit signals from(bottom class) mplayer.cpp.
@ this->m_process->setProgram(program);
this->m_process->setArguments(arguments);this->m_process->start(); if(this->m_process->state()==QProcess::Running) { qDebug("\nSuccess in starting Process = Mplayer"); emit Running(); } if(!this->m_process->waitForStarted()) { qDebug("\nFailed To start Process = Mplayer"); }
}
mplayer::~mplayer()
{
qDebug("\nDeleting Process = Mplayer");
emit Not_Running();
this->m_process->close();
}
@mplayer.h
@#ifndef MPLAYER_H
#define MPLAYER_H#include <QWidget>
#include <QProcess>class mplayer : public QWidget
{
Q_OBJECT
public:
explicit mplayer(QWidget *parent = 0);
~mplayer();signals:
void Running();
void Not_Running();
void Initialised();private:
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.
-
wrote on 14 Aug 2014, 09:26 last edited by
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.
1/3