PDA

View Full Version : slot to execute (or initialize) my program



21did21
3rd September 2011, 17:10
hello world,

i have a program "myProgramm.exe" when i run it, it runs calculation. Now i have put a button (with a slot) used to run the principale function (because i don't want run the calcul a the beginning of the execution).
To stop my programm i click on the STOP button which it break the loop of calculation and induce the end of the programme.

This thing works nice but when i STOP my programm i can't RUN it by a click on the RUN button: i must close end rerun my ".exe" before clicking on the RUN button.

to avoid this i think i have to:
- either i create a slot which it initialize my programm (rerun the function main.cpp)
- or i replace my run button by a button which rerun my .exe

but i don't know how i can make this....

can you help me (please, use a easy english because mine is not perfect)

thank you

mvuori
3rd September 2011, 18:39
Don't do your calculation in main().

Put the code in a class (like MyCalculator : public QObject) and initialize and start the run in a slot run().

In your main() you just create an object based on this class and connect the buttons to its slots (start() and stop().

21did21
3rd September 2011, 22:59
can i havve an example please ?
thank you