PDA

View Full Version : QEventLoop not closing



kuku83
9th April 2013, 18:38
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

ChrisW67
9th April 2013, 22:07
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.

kuku83
10th April 2013, 08:55
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

MarekR22
10th April 2013, 13:49
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.

kuku83
10th April 2013, 17:01
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::processEvents(QEventLoop::AllEvents)

It doesn´t works :-(