Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Automatically Activate Buttons in GUI
FuryDol last edited by
i created a GUI on which after start of the GUI I sequentially have to press a few buttons which starts different functions that have to be started one after another (always in the same order).
Is it possible to insert a function that at boot up of the guiwindow automatically presses the buttons one after another?
I tried implementing this in the constructor (didn't work) and after that i tried it in the main (didn't work either) - Perhaps with a sleep() or delay function? Any ideas? Thx for your help
IamSumit last edited by
Hi and welcome to devnet.
Yes this is posible.
you can use QTimer for that.and set interval b/w one button to another button.
to activate that button just emit clicked() signal then it automatically pressed/activated.
Hope this helps.
Hi and welcome to devnet,
If each button should be pressed one after the other, are you sure that the design is the best ? Why not have e.g. a state machine ? Or simply each function calling the following using e.g. a QTimer::singleShot ?
FuryDol last edited by
To the design: I want to have a manual and a automatic mode of the programm - so one where automatically all "basic settings / functions" are loaded or another startup possiblity where it is possible to configure setting by just selecting different buttons/options.
But what I don't understand is where to put the "emit and QTimer" - could you give me a code example? Because if my constructor is called i am somehow not able to call a button as toggled. At the Beginning no button is called so i need to define the QTimer in the Konstruktor - but somehow it doesnt work. And they have to be toogled and not clicked. Or would i need "global declarations"?
GUIWindow::GUIWindow(QWidget *parent) :
If you have these two distinct modes, then you should maybe re-think your architecture.
Again, it sounds like you should rather have a state machine. Using one you can move it step by step with your buttons or let it run alone when in automatic mode. This would also allow you to change your GUI without having to rethink your complete core logic if needed