简体   繁体   English

Qt - 究竟是什么QWidget

[英]Qt - What exactly is QWidget

In the C++ GUI Programming with Qt 4 book, it mentions in an example in the first chapter that QWidget serves as the application's main window . C++ GUI Programming with Qt 4C++ GUI Programming with Qt 4一书中,它在第一章的一个例子中提到QWidget作为应用程序的主窗口

And, on the Qt Reference Documentation : http://doc.qt.io/qt-4.8/qwidget.html there is plenty of information about QWidget. 而且,在Qt Reference Documentationhttp//doc.qt.io/qt-4.8/qwidget.html上有很多关于QWidget的信息。

But, what is the baseline? 但是,基线是什么? What does QWidget mainly do? QWidget主要做什么? When should I think about it? 我应该什么时候考虑一​​下?

One way to think about it is any object that knows how to display itself on the screen is a QWidget (in particular, some subclass of QWidget). 考虑它的一种方法是知道如何在屏幕上显示自己的任何对象是QWidget(特别是QWidget的一些子类)。

There are some objects like QPicture that represent an image, but a QPicture by itself doesn't know how to put itself on the screen. 有些像QPicture的对象代表一个图像,但QPicture 本身并不知道如何将自己置于屏幕上。 You usually need to use it in combination with a QLabel for instance (which is a kind of QWidget). 您通常需要将它与QLabel结合使用(这是一种QWidget)。

It is an abstract of window objects. 它是窗口对象的摘要。 Every visible/invisible Qt window-related object inherits from QWidget. 每个可见/不可见的Qt窗口相关对象都继承自QWidget。

Just consider a vehicle, it is the abstract of cars, trucks and other stuffs. 只考虑一辆车,它是汽车,卡车和其他东西的摘要。

Widget is X11 parlance for something a bit more generic that what other systems call a control . Widget是X11的说法,用于比其他系统称为控件更通用的东西。 A widget can be a pushbutton, a listview, a window, etc... 小部件可以是按钮,列表视图,窗口等......

And BTW, it supposedly comes from Window Gadget . 据推测,它应该来自Window Gadget

In windowing systems like X11, there is no difference between a toplevel window and a widget. 在像X11这样的窗口系统中,顶层窗口和窗口小部件之间没有区别。 All are called "windows", and all of them have a parent and children (except the root window, which is usually what the desktop wallpaper is drawn on). 所有这些都被称为“窗口”,它们都有父和子(根窗口除外,这通常是桌面壁纸的绘制)。 So it makes sense that a widget can either be a toplevel window (ie a child of the root window) or any other window. 因此,窗口小部件可以是顶层窗口(即根窗口的子窗口)或任何其他窗口是有意义的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM