窗口和对话框区别(Window和Dialog) 主窗口和二级窗口区别(Primary and Secondary Windows) QMainWindow和QDialog区别 QtShare Qt学习 Qt系列教程

  • A+
所属分类:Qt系列教程

窗口和对话框(Window and Dialog Widgets)

英文

A widget that is not embedded in a parent widget is called a window. (Usually, windows have a frame and a title bar, although it is also possible to create windows without such decoration using suitable window flags). In Qt, QMainWindow and the various subclasses of QDialog are the most common window types.

In applications, windows provide the screen space upon which the user interface is built. Windows separate applications visually from each other and usually provide a window decoration that allows the user to resize and position the applications according to his preferences. Windows are typically integrated into the desktop environment and to some degree managed by the window management system that the desktop environment provides. For instance, selected windows of an application are represented in the task bar.

中文

未嵌入在父界面中的界面称为窗口。(通常,窗口具有边框和标题栏,尽管也可以使用合适的窗口标志创建没有此类标志的窗口)。在Qt中,QMainWindow和QDialog的各个子类是最常见的窗口类型。

在应用程序中,窗口提供构建用户界面的屏幕区域。Windows 在视觉上将应用程序彼此分开,并且通常提供窗口修饰,允许用户根据自己的喜好调整应用程序的大小和位置。Windows通常集成到桌面环境中,并在某种程度上由桌面环境提供的窗口管理系统管理。例如,选中应用程序的窗口会显示在任务栏中。

总结

QMainWindow和QDialog都是window,不是普通界面。

主窗口和二级窗口(Primary and Secondary Windows)

英文

Any QWidget that has no parent will become a window, and will on most platforms be listed in the desktop's task bar. This is usually only wanted for one window in the application, the primary window.

In addition, a QWidget that has a parent can become a window by setting the Qt::Window flag. Depending on the window management system such secondary windows are usually stacked on top of their respective parent window, and not have a task bar entry of their own.

The QMainWindow class sets the Qt::Window flag in its constructor, as it is designed to be used as a window and provides facilities that are not wanted for child widgets.

中文

任何没有父亲的QWidget都会成为一个窗口,并且在大多数平台上都会列在桌面的任务栏中。一个应用程序通常只需要一个窗口,即主窗口。

此外,具有父亲的 QWidget 可以通过设置 Qt::Window 标志成为窗口。窗口管理系统通常会将此类二级窗口堆叠在其各自的父窗口之上,并且没有自己的任务栏条目。

QMainWindow 类在其构造函数中设置 Qt::Window 标志,因为它被设计用作窗口并提供子界面不需要的功能。

总结

QmainWindow是主窗口,QDialog其实是二级窗口,应该就是通过继承QWidget 并设置 Qt::Window 标志实现。

Main Windows and Dialogs(主窗口和对话框)

英文

The Application Main Window provides the framework for building the application's main user interface, and are created by subclassing QMainWindow. QMainWindow has its own layout to which you can add a menu bar, tool bars, dockable widgets and a status bar. The center area can be occupied by any kind of QWidget.

Dialog Windows are used as secondary windows that present the user with options and choices. Dialogs are created by subclassing QDialog and using widgets and layouts to implement the user interface. In addition, Qt provides a number of ready-made standard dialogs that can be used for standard tasks like file or font selection.

中文

应用程序主窗口通过子类化 QMainWindow 提供用于构建应用程序主要用户界面的框架。QMainWindow有自己的布局,您可以在其中添加菜单栏、工具栏、可停靠的小部件和状态栏。中心区域可以被任何类型的QWidget占据。

对话框窗口被用作二级窗口,为用户提供选项和选择。对话框是通过子类化 QDialog 并使用小部件和布局来实现用户界面的创建。此外,Qt还提供了许多现成的标准对话框,可用于文件或字体选择等标准任务。

总结

QmainWindow是主窗口,QDialog其实是二级窗口

发表评论

您必须登录才能发表评论!