5
votes

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?

4
Do you understand OOP ? Actually working through a few examples should help you grasp what QWidget is. - Alexandre C.

4 Answers

7
votes

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

4
votes

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.

1
votes

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.

1
votes

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.