PDA

View Full Version : Play/Pause QPushButton



mittins
23rd March 2015, 21:08
I am attempting to add a "Play/Pause" QPushButton for a tile morphing app. My issue is that this button should have two functions in itself (play/pause).

How would I go about adding the pause functionality? My current code has the play function working:

GLWidget.cpp


void GLWidget::s_play()
{
m_flagScale = 1;
m_flagCentroid = 1;
m_flagRotate = 1;
}


MainWindow.cpp


connect(m_load, SIGNAL(clicked()), this, SLOT(s_loadTiles()));
connect(m_scale, SIGNAL(stateChanged(int)), m_glwidget, SLOT(s_setScale(int)));
connect(m_rotate, SIGNAL(stateChanged(int)), m_glwidget, SLOT(s_setRotate(int)));
connect(m_centroid, SIGNAL(stateChanged(int)), m_glwidget, SLOT(s_setCentroid(int)));
connect(m_play, SIGNAL(clicked()), m_glwidget, SLOT(s_play()));


Thank for the help in advance!

stampede
24th March 2015, 00:51
What about something like this


void GLWidget::switch_play_state()
{
if (m_isPaused == false )
this->s_pause(); // sets m_isPaused=true;
else
this->s_play(); // sets m_isPaused=false;
}

//

connect(m_play, SIGNAL(clicked()), m_glwidget, SLOT(switch_play_state()));