Results 1 to 2 of 2

Thread: Play/Pause QPushButton

  1. #1
    Join Date
    Mar 2015
    Posts
    1
    Qt products
    Qt5
    Platforms
    MacOS X

    Default Play/Pause QPushButton

    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
    Qt Code:
    1. void GLWidget::s_play()
    2. {
    3. m_flagScale = 1;
    4. m_flagCentroid = 1;
    5. m_flagRotate = 1;
    6. }
    To copy to clipboard, switch view to plain text mode 

    MainWindow.cpp
    Qt Code:
    1. connect(m_load, SIGNAL(clicked()), this, SLOT(s_loadTiles()));
    2. connect(m_scale, SIGNAL(stateChanged(int)), m_glwidget, SLOT(s_setScale(int)));
    3. connect(m_rotate, SIGNAL(stateChanged(int)), m_glwidget, SLOT(s_setRotate(int)));
    4. connect(m_centroid, SIGNAL(stateChanged(int)), m_glwidget, SLOT(s_setCentroid(int)));
    5. connect(m_play, SIGNAL(clicked()), m_glwidget, SLOT(s_play()));
    To copy to clipboard, switch view to plain text mode 

    Thank for the help in advance!

  2. #2
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,391
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Play/Pause QPushButton

    What about something like this
    Qt Code:
    1. void GLWidget::switch_play_state()
    2. {
    3. if (m_isPaused == false )
    4. this->s_pause(); // sets m_isPaused=true;
    5. else
    6. this->s_play(); // sets m_isPaused=false;
    7. }
    8.  
    9. //
    10.  
    11. connect(m_play, SIGNAL(clicked()), m_glwidget, SLOT(switch_play_state()));
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. QtConcurrent pause
    By MarKac in forum Newbie
    Replies: 2
    Last Post: 23rd April 2013, 14:49
  2. Pause at each row in QTextEdit
    By lamb in forum Qt Programming
    Replies: 2
    Last Post: 27th September 2012, 12:05
  3. [Tab play list]Load play lists on start
    By petrusPL in forum Qt Programming
    Replies: 0
    Last Post: 18th March 2011, 18:12
  4. I need a pause (QTimer)
    By baray98 in forum Qt Programming
    Replies: 3
    Last Post: 17th January 2008, 05:37
  5. create play,pause and stop buttons
    By Sheetal in forum Qt Tools
    Replies: 6
    Last Post: 31st January 2007, 14:23

Tags for this Thread

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.