Label change and corrosponding action on pushbutton

  • I want to add a pushbutton which can initiate or terminate the data processing. Initially label on button should be "initiate"-clicking on it starts prcessing. As this button is clicked label should change to " terminate". If terminate is clicked- it should stop processing of data and label on button should change to "initiate"....and so on.

    Kindly suggest the solution..

  • Lifetime Qt Champion

    How do you interrupt the processing ?
    Are you using threads or do you want to call a function repeatedly ?
    If you are think about any kind of loop. that's not it. long lasting loops don't play well with GUI :)

    Can you tell about bit more about the processing?
    You could use push buttons checkbox feature.
    so when "down" it starts a time and in timers slot perform processing.
    if unchecked, it calls timer stop.

  • @mrjj Hi,
    Here processing of data is reading data from file and plotting it. When clicked on initiate, starts plotting and changes the label to terminate. When terminate on same button is clicked, plotting is stopped and label of same button changes to initiate.

  • Qt Champions 2018

    Not super elegant but it works

    const QString initiateText = tr("initiate");


    See page 171 of C++ GUI Programming with Qt 4

Log in to reply

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