Results 1 to 7 of 7

Thread: How to access main loop

  1. #1
    Join Date
    Dec 2014
    Posts
    82
    Thanks
    10
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default How to access main loop

    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!

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to access main loop

    See QTimer. It can be used to repeatedly call a method through Qt's signal/slot mechanism.

    Cheers,
    _

  3. #3
    Join Date
    Dec 2014
    Posts
    82
    Thanks
    10
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to access main loop

    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?

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to access main loop


  5. #5
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to access main loop

    Quote Originally Posted by roseicollis View Post
    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.

  6. #6
    Join Date
    Jan 2013
    Location
    Bangalore, India
    Posts
    36
    Thanks
    9
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to access main loop

    Which app are you creating? QTGui application, or QTconsole application?

  7. #7
    Join Date
    Dec 2014
    Posts
    82
    Thanks
    10
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to access main loop

    Hi,

    Thank you Lesiok, I'll try it.

    jakr13, I'm making a QTGui app

Similar Threads

  1. Main loop thread loop communication
    By mcsahin in forum Qt Programming
    Replies: 7
    Last Post: 25th January 2011, 17:31
  2. main loop
    By dusza in forum Qt Programming
    Replies: 10
    Last Post: 6th June 2009, 18:29
  3. HAL & DBusConnection & Qt main loop integration
    By juannm in forum Qt Programming
    Replies: 3
    Last Post: 15th January 2009, 09:06
  4. Main Thread Event loop
    By ^NyAw^ in forum Qt Programming
    Replies: 1
    Last Post: 20th March 2007, 13:10
  5. While statement inside the main loop
    By OnionRingOfDoom in forum Qt Programming
    Replies: 4
    Last Post: 8th February 2006, 19:17

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.