[Interest] QWindows and objectNames

Thiago Macieira thiago.macieira at intel.com
Fri Sep 24 19:50:15 CEST 2021

On Friday, 24 September 2021 06:27:31 PDT Tor Arne Vestbø wrote:
> That’s expected. The name of your widget is “myMainWindow”. The name of the
> QWindow (QWidgetWindow) backing that QWidget has the widget name with a
> “Window” suffix.
> Renaming your widget to “myMainWindowWidget” will make it clearer :)

Resulting in a name of "myMainWindowWidgetWindow" ? :)

Yves: you're confusing QWindows and QWidgets. For historical reasons, 
QMainWindow is a widget, not a window. It's a very old class, dating back to 
the very early 1990s, when Qt didn't have a distinction between widgets and 
windows. Until 5.0, the a (top-level) window simply was any widget that had no 
parent widget. That's why some API in QtWidgets has "Window" in the name, such 
as QMainWindow and QApplication::activeWindow().

When Qt 5.0 split the widget content from QtGui into QtWidgets, it added 
QWindow, which is always a windowing system window, but carries no widget 
baggage. All QWidgets that have no parent (and some that do) are also 
associated with a QWindow. That's where the "Window" suffix gets added.

Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel DPG Cloud Engineering

More information about the Interest mailing list