Simplicity
Simplicity

Reputation: 48966

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.

And, on the Qt Reference Documentation: http://doc.qt.io/qt-4.8/qwidget.html there is plenty of information about QWidget.

But, what is the baseline? What does QWidget mainly do? When should I think about it?

Upvotes: 5

Views: 4125

Answers (4)

mtk358
mtk358

Reputation: 565

In windowing systems like X11, there is no difference between a toplevel window and a widget. 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 (i.e. a child of the root window) or any other window.

Upvotes: 1

ninjalj
ninjalj

Reputation: 43748

Widget is X11 parlance for something a bit more generic that what other systems call a control. A widget can be a pushbutton, a listview, a window, etc...

And BTW, it supposedly comes from Window Gadget.

Upvotes: 1

Greg Hewgill
Greg Hewgill

Reputation: 994539

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).

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. You usually need to use it in combination with a QLabel for instance (which is a kind of QWidget).

Upvotes: 7

xis
xis

Reputation: 24850

It is an abstract of window objects. Every visible/invisible Qt window-related object inherits from QWidget.

Just consider a vehicle, it is the abstract of cars, trucks and other stuffs.

Upvotes: 4

Related Questions