What's the difference between QMainWindow, QWidget and QDialog?

自闭症网瘾萝莉.ら 提交于 2019-11-27 09:06:56

问题


What's the difference between QMainWindow, QWidget and QDialog?


回答1:


A QWidget is the base class for all drawable classes in Qt. Any QWidget-based class can be shown as a window by showing it when it has no parent.

A QDialog is based on QWidget, but designed to be shown as a window. It will always appear in a window, and has functions to make it work well with common buttons on dialogs (accept, reject, etc.).

QMainWindow is designed around common needs for a main window to have. It has predefined places for a menu bar, a status bar, a toolbar, and other widgets. It does not have any built-in allowances for buttons like QDialog does.




回答2:


QWidget :is a base class for all other GUI elements in QtWidgets module. It can constitute a window by itself, or be part of a QLayout, or just a member of parent-child hierarchy.

QDialog :is usually used to - surprise! - display a temporary dialog when user input is required.

QMainWindow :is a convenience class that can be used as the main window of your application. It has some nice features built-in: a status bar, tool bars and a menu bar



来源:https://stackoverflow.com/questions/3298792/whats-the-difference-between-qmainwindow-qwidget-and-qdialog

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!