Qt Slot Execution Order



  • Status:Closed
  • Resolution: Invalid
  • Fix Version/s: None
  • Labels:
  • Environment:
    Ubuntu 16.04 and Windows 10 both using Qt 5.9.1

Summary

The connection mechanism uses a vector indexed by signals. But all the slots waste space in the vector and there are usually more slots than signals in an object. So from Qt 4.6, a new internal signal index which only includes the signal index is used. While developing with Qt, you only need to know about the absolute method index. Detailed Description. The QObject class is the base class of all Qt objects. QObject is the heart of the Qt Object Model.The central feature in this model is a very powerful mechanism for seamless object communication called signals and slots.

The order of event execution differs between Linux and Windows for mousePressEvent, mouseReleaseEvent, and contextMenuEvent.

Qt Slot Execution Order Diagram

Description

Attached is a small qt project that will reproduce the issue. It is just a QPushButton that prints when it receives the above-mentioned events.

Note: On windows I had to #undef main before the main function to get it to compile.

Expected behavior:

The events are processed in the same order on Linux and Windows.

Actual behavior:

When right clicking the widget that appears, on Linux the events will be processed in the following order:

MOUSE DOWN
CONTEXT MENU
MOUSE UP

On Windows the events will be processed in the following order:

MOUSE DOWN
MOUSE UP
CONTEXT MENU

Environment

Linux:

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04.2 LTS
Release: 16.04
Codename: xenial

Qt Version: 5.9.1 (installed from qt installer)

Execution

Windows:

Qt Signal Slot Execution Order

Slot

OS: Windows 10

Qt Version: 5.9.1 (installed from qt installer)

Attachments

Gerrit Reviews

No reviews matched the request. Check your Options in the drop-down menu of this sections header.
Assignee:
Gatis Paeglis
Reporter:
Christopher Pezley
Votes:
0Vote for this issue
Watchers:
2Start watching this issue