Questions tagged [qeventloop]

The QEventLoop class, part of the Qt framework, provides a means of entering and leaving an event loop.

At any time, you can create a QEventLoop object and call exec() on it to start a local event loop. From within the event loop, calling exit() will force exec() to return.

The official Qt documentation can be found here for Qt 4.8 and here for Qt 5.

99 questions
3
votes
1 answer

Quamash QventLoop "RuntimeError: no running event loop" error in python and PyQt5

I don't seem to find the right solution to this error. The program keep giving "RuntimeError: no running event loop". Why is the event loop not running? import sys import asyncio import time from PyQt5.QtWidgets import QApplication, QWidget,…
kelvinmacharia254
  • 117
  • 1
  • 3
  • 12
3
votes
2 answers

Executing slot on every application's event loop iteration

How can I call my slot on every iteration of application's event loop? Only way I know is to use QTimer and on every timeout (every millisecond) signal I can call my slot. But I don't like this option, it looks like workaround. Any suggestions how…
asmodan
  • 85
  • 1
  • 6
3
votes
1 answer

Qt add function call to event loop from other thread

I've stumbled across a problem I can't solve on an elegant way right now. The situation: I have a callback function which is called from outside my application. The callback function has to update some gui object.. Since I can't call (for example)…
ruhig brauner
  • 943
  • 1
  • 13
  • 35
3
votes
1 answer

Confusion regarding QThread, QObject, Thread Affinity and Event Loop

I was going through the links You are doing it wrong Using QThread in right way Part1 Using QThread in right way Part2 I got confused by some statements. In the first link, it says that all of the functions in QThread were written and intended to…
Rakib
  • 7,435
  • 7
  • 29
  • 45
2
votes
1 answer

How to avoid races if a signal is emitted before calling QObject::connect()?

In Qt, how does one avoid race conditions if signals can be emitted around the same time when I connect to them? Consider the following naïve example: MySignalSender *sender = new MySignalSender(); // starts async operation that emits `fooSignal` //…
Petr Mánek
  • 1,046
  • 1
  • 9
  • 24
2
votes
1 answer

Qt thread execution does not stop after exit() quit() or terminate() was called

First off, I have read up on QThreads and using the QEventLoop but I am not entirely sure my implementation is correct. TL;DR see Problem Details below. Most useful sources of information is Qt Wiki, KDAB Qthread presentation (useful for w/ & w/o…
CybeX
  • 2,060
  • 3
  • 48
  • 115
2
votes
2 answers

QCoreApplication::processEvents - why must it be called from main thread only?

Since there is only one QCoreApplication object, why does it matter from which thread QCoreApplication::processEvents() is called? After all, the threads all share the same address space.
Bob
  • 4,576
  • 7
  • 39
  • 107
2
votes
0 answers

QRenderCapture saves strange screenshots

Our company is in need to capture the rendering of a Qt3d scene. For this I created a small example application, that illustrates the usage of our capturing. On the left-hand side you will find the 3D scene and on the right-hand side there is a…
Aleph0
  • 5,816
  • 4
  • 29
  • 80
2
votes
2 answers

Race condition with QThread/QDialog

I'm trying to avoid a race condition in the following scenario: QDialog* dialog = [...]; QThread* thread = [...]; connect(thread, SIGNAL(finished()), dialog, SLOT(accept())); thread->start(); dialog->exec(); When the thread finishes before…
hmn
  • 716
  • 7
  • 18
2
votes
1 answer

Recovering from error in Qt

I'm implementing a system that uses 3 threads (one is GUI, one is TCP client for data acquisition and one analysis thread for calculations). I'm having a hard time handling an exception for either one. The case that I'm trying to solve now is what…
JLev
  • 705
  • 1
  • 9
  • 30
2
votes
0 answers

Fudging QWebEngine to run Javascript code 'synchronously'

I am using QWebEngine and I would like to run some Javascript synchronously! Or at least pretend to. So I came up with an ol' classic, using QEventLoop to wait. I call this code from my QWebEngineView derived class: void MyView::doSomething() { …
Addy
  • 2,414
  • 1
  • 23
  • 43
2
votes
2 answers

Run QFileDialog::getOpenFileName without separate event loop?

I'm using QFileDialog::getOpenFileName right now. However, as suggested in this article, this crashes when the main application closes while the dialog is open. You can see an example of how to reproduce the crash here: int main(int argc, char…
Jan Rüegg
  • 9,587
  • 8
  • 63
  • 105
2
votes
2 answers

Qt or any other lang. Event Loop

I'm a c++ programmer on Qt platform. I'm wondering, how does the event loop "knows" to which widget to send an event, mainly mouse/keyboard events? Is it done based on mouse coordinates and z-order? What about events from keyboard? Thanks
ClimbingLung
  • 219
  • 2
  • 8
2
votes
2 answers

QDialog popping up another QDialog

I have a subclassed QDialog containing a bunch of subclassed QSpinBox's. When clicking a spinbox, a keypad (another QDialog) where you can use pushbuttons to enter digits. Both QDialog's are activated by calling QDialog::exec(); However, when…
Pieter
  • 1,191
  • 1
  • 11
  • 29
2
votes
1 answer

How QEventLoop must be used when we don't subclass QThread in Qt 4.8x?

I've read there are two approaches for working with QThread. If I have a Worker class, which inherits QObject (as in http://mayaposch.wordpress.com/2011/11/01/how-to-really-truly-use-qthreads-the-full-explanation/), then how should I create and…
ilya
  • 1,103
  • 14
  • 36