Window and Dialog Widgets
没有嵌入到父控件中的控件(widget)称之为窗口(window)。通常窗口带有边框和标题栏。
Windows通常集成到桌面环境中,并且在某种程度上由桌面环境提供的窗口管理系统管理。例如,应用程序的选定窗口在任务栏中表示。
Primary and Secondary Windows
任何没有父组件的QWidget都将成为一个窗口,并且在大多数平台上都将在桌面的任务栏中列出。这通常只适用于应用程序中的一个窗口,即主窗口。
此外,通过设置Qt:: window标志,具有父组件的QWidget可以成为一个窗口。根据窗口管理系统的不同,这些辅助窗口通常堆叠在各自的父窗口之上,并且没有自己的任务栏条目。
QMainWindow类在其构造函数中设置了Qt::Window标志,因为它被设计为用作窗口,并提供了子部件不需要的工具。
Main Windows and Dialogs
略
Window Geometry
- Including the window frame: x(), y(), frameGeometry(), pos(), and move().
- Excluding the window frame: geometry(), width(), height(), rect(), and size().
X11 Peculiarities
On X11, a window does not have a frame until the window manager decorates it. This happens asynchronously at some point in time after calling QWidget::show() and the first paint event the window receives, or it does not happen at all. Bear in mind that X11 is policy-free (others call it flexible). Thus you cannot make any safe assumption about the decoration frame your window will get. Basic rule: There‘s always one user who uses a window manager that breaks your assumption, and who will complain to you.
Furthermore, a toolkit cannot simply place windows on the screen. All Qt can do is to send certain hints to the window manager. The window manager, a separate process, may either obey, ignore or misunderstand them. Due to the partially unclear Inter-Client Communication Conventions Manual (ICCCM), window placement is handled quite differently in existing window managers.
X11 provides no standard or easy way to get the frame geometry once the window is decorated. Qt solves this problem with nifty heuristics and clever code that works on a wide range of window managers that exist today. Don‘t be surprised if you find one where QWidget::frameGeometry() returns wrong results though.
Nor does X11 provide a way to maximize a window. QWidget::showMaximized() has to emulate the feature. Its result depends on the result of QWidget::frameGeometry() and the capability of the window manager to do proper window placement, neither of which can be guaranteed.
原文地址:https://www.cnblogs.com/pplxlee/p/10976338.html