-3

I am trying to customize a pushbutton in such a way that when the pushbutton is clicked and held the process will be executed once released the process is stopped ?

Since I am new to qt any help would be appreciated.

ΦXocę 웃 Пepeúpa ツ
  • 47,427
  • 17
  • 69
  • 97

2 Answers2

1

Check the signals of QPushButton like triggered, pressed released... With these, you can handle your execution of the process!

F.Guerinoni
  • 277
  • 2
  • 12
0

you can set the button property "autoRepeat" to true. then after that play with the initial delay and the frequency for the signal emission...

enter image description here

you have to connect the signal/slots of course...

and after that you can call the process repeatedly

void MainWindow::on_pushButton_5_clicked()
{
    qDebug() << "HelloWorld";
}

"Debug@2020.03.09 08:33:25.897 CET - HelloWorld"

"Debug@2020.03.09 08:33:26.918 CET - HelloWorld"

"Debug@2020.03.09 08:33:27.918 CET - HelloWorld"

"Debug@2020.03.09 08:33:28.918 CET - HelloWorld"

"Debug@2020.03.09 08:33:29.149 CET - HelloWorld"

ΦXocę 웃 Пepeúpa ツ
  • 47,427
  • 17
  • 69
  • 97
  • Thanks for the reply !! Your method works for the case where the process is a short one like printing "hello world", but in my case i am trying to control a processBar so the function is when i press and hold the pushbutton, processBar should change and when i release the button the processBar should stop at that point itself. I tried using pushButton_pressed but once i press the pushButton processbar starts running even after i release it the progessBar continues to run. – MajinRanga Mar 10 '20 at 05:27
  • then you should had explained that in the description of your question – ΦXocę 웃 Пepeúpa ツ Mar 10 '20 at 06:24