Results 1 to 5 of 5

Thread: QEventLoop not closing

  1. #1

    Default QEventLoop not closing

    Hi,

    I have an EventLoop defined like this

    void MyWindow()

    m_Loop = new QEventLoop() -- class parameter
    --do stuff
    --connect keyPressed - quit(m_loop)
    m_loop.exec() --In order to wait a keyPressed and close the window


    ... If we wait a lot of time in order to press the key, an energy-saver begins its execution, we have connected a QTimer (120 seconds) to a slot called EnergySaver()

    Inside the slot we do:

    m_loop.exit() -- In order to end and close the window because of energy-saver.

    The problem is that this exit() is executing a lot of instructions after it was called.

    Why?

    Thanks in advance

    K

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,641
    Thanks
    13
    Thanked 1,592 Times in 1,520 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QEventLoop not closing

    We have no idea what the rest of your program does after the m_loop.exec() call returns. Calling exit() on the QEventLoop has nothing to do with closing windows or applications.

  3. #3

    Default Re: QEventLoop not closing

    The real problem is that I don't know why exit is not executing inmediatly.

    Do you know the reason?

    Here some aclaration :

    m_Loop = new QEventLoop() -- class parameter
    --do stuff
    --connect keyPressed - quit(m_loop)
    m_loop.exec() --In order to wait a keyPressed and close the window
    -- End the window


    The problem is that exit invoked from the other slot is not executing inmediatly

  4. #4
    Join Date
    Nov 2010
    Posts
    315
    Thanked 53 Times in 51 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QEventLoop not closing

    event loop works by calling processEvents after wait for new events.
    processEvents works until event queue is empty.
    If you have some widgets which get shown lots of things may happen after event loop is activated (loading style, processing layouts, painting, ...).
    So how fast event loop returns depends on that what kind of objects you have active and what is the state of this objects.

  5. #5

    Default Re: QEventLoop not closing

    Then, there is any way to force eventLoop to quit inmediatly from EnergySaver slot?


    Added after 1 29 minutes:


    I tried to force system to invoke inmediatly the eventLoop-quit slot executing inside energySaver slot

    QApplication:rocessEvents(QEventLoop::AllEvents)

    It doesn´t works :-(
    Last edited by kuku83; 10th April 2013 at 16:01.

Similar Threads

  1. QEventLoop in QApplication
    By Qiieha in forum Qt Programming
    Replies: 1
    Last Post: 22nd May 2012, 19:08
  2. QThread and QEventLoop - Idle Processing
    By kloffy in forum Newbie
    Replies: 14
    Last Post: 28th April 2011, 11:41
  3. QTest and QEventLoop inside a library
    By MementoMori in forum Qt Programming
    Replies: 1
    Last Post: 22nd February 2011, 15:38
  4. How to use QEventLoop?
    By MorrisLiang in forum Newbie
    Replies: 3
    Last Post: 13th May 2010, 16:23
  5. qprocess or qeventloop
    By knishaq in forum Qt Programming
    Replies: 1
    Last Post: 20th December 2009, 10:14

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.