QMainWindow,QWidget和QDialog有什么区别?

问题描述:

QMainWindow,QWidget和QDialog有什么区别?

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

QWidget是Qt中所有可绘制类的基类.任何基于QWidget的类都可以在没有父类的情况下显示为窗口.

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基于QWidget,但旨在显示为窗口.它将始终显示在窗口中,并具有使其与对话框上的常用按钮(接受,拒绝等)配合使用的功能.

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围绕主窗口的常见需求而设计.它具有用于菜单栏,状态栏,工具栏和其他小部件的预定义位置.像QDialog一样,它没有按钮的内置余量.

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.