[go: up one dir, main page]

0% found this document useful (0 votes)
30 views3 pages

Pyqt5 Class References: Detailed Description

The QWidget class is the base class for all user interface objects in PyQt5 and inherits from QObject and QPaintDevice, it represents a widget that can be displayed on screen and receives mouse, keyboard, and other events while painting itself on screen, with QWidget having many methods but subclasses like QLabel and QPushButton providing actual functionality for labels, buttons and other common widgets.

Uploaded by

Bhaisahab singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views3 pages

Pyqt5 Class References: Detailed Description

The QWidget class is the base class for all user interface objects in PyQt5 and inherits from QObject and QPaintDevice, it represents a widget that can be displayed on screen and receives mouse, keyboard, and other events while painting itself on screen, with QWidget having many methods but subclasses like QLabel and QPushButton providing actual functionality for labels, buttons and other common widgets.

Uploaded by

Bhaisahab singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

PyQt5 Class references

Class QtWidget
https://het.as.utexas.edu/HET/Software/PyQt/qwidget.html#details
The QWidget class is the base class of all user interface objects.
Inherits QObject and QPaintDevice.
Methods(not all methods)

 __init__ (self, QWidget parent = None, Qt.WindowFlags flags = 0)

 addAction (self, QAction action)
 addActions (self, list-of-QAction actions)
 setFocus (self)
 setFocus (self, Qt.FocusReason reason)
 setMask (self, QBitmap)
 setMask (self, QRegion)
 setMaximumHeight (self, int maxh)
 setMaximumSize (self, int maxw, int maxh)
 setMaximumSize (self, QSize s)
 setMaximumWidth (self, int maxw)
 setMinimumHeight (self, int minh)
 setMinimumSize (self, int minw, int minh)
 setMinimumSize (self, QSize s)
 setMinimumWidth (self, int minw)

Detailed Description
The QWidget class is the base class of all user interface objects.

The widget is the atom of the user interface: it receives mouse, keyboard and other
events from the window system, and paints a representation of itself on the screen.
Every widget is rectangular, and they are sorted in a Z-order. A widget is clipped by
its parent and by the widgets in front of it.
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.

Every widget's constructor accepts one or two standard arguments:

1. QWidget *parent = 0 is the parent of the new widget. If it is 0 (the default),
the new widget will be a window. If not, it will be a child of parent, and be
constrained by parent's geometry (unless you specify Qt.Window as
window flag).
2. Qt.WindowFlags f = 0 (where available) sets the window flags; the default
is suitable for almost all widgets, but to get, for example, a window without
a window system frame, you must use special flags.

QWidget has many member functions, but some of them have little direct
functionality; for example, QWidget has a font property, but never uses this itself.
There are many subclasses which provide real functionality, such
as QLabel, QPushButton, QListWidget, and QTabWidget.

Top-Level and Child Widgets

A widget without a parent widget is always an independent window (top-level


widget). For these widgets, setWindowTitle() and setWindowIcon() set the title bar
and icon respectively.

Non-window widgets are child widgets, displayed within their parent widgets. Most
widgets in Qt are mainly useful as child widgets. For example, it is possible to display
button as a top-level window, but most people prefer to put their buttons inside other

widgets, such as QDialog.

You might also like