Frank
Frank

Reputation: 2696

Set priority to events

I am making an application in QT. I use QExtSerialPort to receive data from the serial port of my comp (whenever the readyread() signal is emitted). I also have some timers running doing other stuff at certain intervals. Now I noticed that when the timers are turned on, not all the data of the readyread signal is emitted a lot less, then when the timers are not turned on. Is there a way in QT to make sure that all the data of the serial port is received? Maybe by setting a high priority to the readyread event or something like that?

Upvotes: 5

Views: 7202

Answers (1)

Pie_Jesu
Pie_Jesu

Reputation: 1914

There is difference between signal-slot connections and event system. Signal emitting and slot triggering are not separate things — when signal is emitted, connected slots begin to work. So they (signals) can't be lost.

All events are sent through application, and also are received, but it can happen later. When control returns to the main event loop, all events that are stored in the queue, will be processed.

If you are posting events yourself, you can use static void QCoreApplication::postEvent ( QObject* receiver, QEvent* event, int priority ); method. Events are sorted in descending priority order, i.e. events with a high priority are queued before events with a lower priority. The priority can be any integer value, i.e. between INT_MAX and INT_MIN, inclusive; see Qt::EventPriority for more details. Events with equal priority will be processed in the order posted.

Upvotes: 6

Related Questions