PDA

View Full Version : How to access main loop



roseicollis
17th December 2014, 09:26
Hi!
I know there is a loop runing when you make an app in Qt... so my question is... how can I access it?

I want to call a function every second.

Also I want to show an Image 1 second every 5 seconds.

Thank you!

anda_skoa
17th December 2014, 09:33
See QTimer. It can be used to repeatedly call a method through Qt's signal/slot mechanism.

Cheers,
_

roseicollis
18th December 2014, 14:56
Hi,

I already saw a QTimer but wasn't sure if I could use it without problems.

Then you can't access the main loop? How can I make a function and call it every second or every milisecond?

anda_skoa
18th December 2014, 15:10
https://qt-project.org/doc/qt-5-snapshot/signalsandslots.html

Cheers,
_

Lesiok
18th December 2014, 17:49
Hi,

I already saw a QTimer but wasn't sure if I could use it without problems.

Then you can't access the main loop? How can I make a function and call it every second or every milisecond?
What problems ? QTimer is an essential tool to periodically perform a task.
Define this function as a slot and connect to them QTimer::timeout signal.

jakr13
19th December 2014, 10:08
Which app are you creating? QTGui application, or QTconsole application?

roseicollis
22nd December 2014, 10:22
Hi,

Thank you Lesiok, I'll try it.

jakr13, I'm making a QTGui app :)