QWidget(3qt)
💖 NAME 💖
okay so bestie, welcome to QWidget(3qt) — the base class of all user interface objects. That's the whole vibe. 👑
🌸 SYNOPSIS 🌸
#include <qwidget.h>
Inherits QObject and QPaintDevice.
Inherited by QAxWidget, QButton, QFrame, QDialog, QComboBox, QDataBrowser, QDataView, QDateTimeEditBase, QDateTimeEdit, QDesktopWidget, QDial, QDockArea, QGLWidget, QHeader, QMainWindow, QMotifWidget, QNPWidget, QScrollBar, QSizeGrip, QSlider, QSpinBox, QSplashScreen, QStatusBar, QTabBar, QTabWidget, QWorkspace, and QXtWidget.
✨ Public Members ✨
explicit QWidget ( QWidget * parent = 0, const char * name = 0, WFlags f = 0 )~QWidget ()WId winId () constQStyle & style () constvoid setStyle ( QStyle * style )QStyle * setStyle ( const QString & style )bool isTopLevel () constbool isDialog () constbool isPopup () constbool isDesktop () constbool isModal () constbool isEnabled () constbool isEnabledTo ( QWidget * ancestor ) constbool isEnabledToTLW () const— obsolete 🫠QRect frameGeometry () constconst QRect & geometry () constint x () constint y () constQPoint pos () constQSize frameSize () constQSize size () constint width () constint height () constQRect rect () constQRect childrenRect () constQRegion childrenRegion () constQSize minimumSize () constQSize maximumSize () constint minimumWidth () constint minimumHeight () constint maximumWidth () constint maximumHeight () constvoid setMinimumSize ( const QSize & )virtual void setMinimumSize ( int minw, int minh )void setMaximumSize ( const QSize & )virtual void setMaximumSize ( int maxw, int maxh )void setMinimumWidth ( int minw )void setMinimumHeight ( int minh )void setMaximumWidth ( int maxw )void setMaximumHeight ( int maxh )QSize sizeIncrement () constvoid setSizeIncrement ( const QSize & )virtual void setSizeIncrement ( int w, int h )QSize baseSize () constvoid setBaseSize ( const QSize & )void setBaseSize ( int basew, int baseh )void setFixedSize ( const QSize & s )void setFixedSize ( int w, int h )void setFixedWidth ( int w )void setFixedHeight ( int h )QPoint mapToGlobal ( const QPoint & pos ) constQPoint mapFromGlobal ( const QPoint & pos ) constQPoint mapToParent ( const QPoint & pos ) constQPoint mapFromParent ( const QPoint & pos ) constQPoint mapTo ( QWidget * parent, const QPoint & pos ) constQPoint mapFrom ( QWidget * parent, const QPoint & pos ) constQWidget * topLevelWidget () constBackgroundMode backgroundMode () constvirtual void setBackgroundMode ( BackgroundMode )void setBackgroundMode ( BackgroundMode m, BackgroundMode visual )const QColor & foregroundColor () constconst QColor & eraseColor () constvirtual void setEraseColor ( const QColor & color )const QPixmap * erasePixmap () constvirtual void setErasePixmap ( const QPixmap & pixmap )const QColorGroup & colorGroup () constconst QPalette & palette () constbool ownPalette () constvirtual void setPalette ( const QPalette & )void unsetPalette ()const QColor & paletteForegroundColor () constvoid setPaletteForegroundColor ( const QColor & )const QColor & paletteBackgroundColor () constvirtual void setPaletteBackgroundColor ( const QColor & )const QPixmap * paletteBackgroundPixmap () constvirtual void setPaletteBackgroundPixmap ( const QPixmap & )const QBrush & backgroundBrush () constQFont font () constbool ownFont () constvirtual void setFont ( const QFont & )void unsetFont ()QFontMetrics fontMetrics () constQFontInfo fontInfo () constconst QCursor & cursor () constbool ownCursor () constvirtual void setCursor ( const QCursor & )virtual void unsetCursor ()QString caption () constconst QPixmap * icon () constQString iconText () constbool hasMouseTracking () constbool hasMouse () constvirtual void setMask ( const QBitmap & bitmap )virtual void setMask ( const QRegion & region )void clearMask ()const QColor & backgroundColor () const— obsolete 🫠virtual void setBackgroundColor ( const QColor & c )— obsolete 🫠const QPixmap * backgroundPixmap () const— obsolete 🫠virtual void setBackgroundPixmap ( const QPixmap & pm )— obsolete 🫠enum FocusPolicy { NoFocus = 0, TabFocus = 0x1, ClickFocus = 0x2, StrongFocus = TabFocus | ClickFocus | 0x8, WheelFocus = StrongFocus | 0x4 }bool isActiveWindow () constvirtual void setActiveWindow ()bool isFocusEnabled () constFocusPolicy focusPolicy () constvirtual void setFocusPolicy ( FocusPolicy )bool hasFocus () constvirtual void setFocusProxy ( QWidget * w )QWidget * focusProxy () constvoid setInputMethodEnabled ( bool b )bool isInputMethodEnabled () constvoid grabMouse ()void grabMouse ( const QCursor & cursor )void releaseMouse ()void grabKeyboard ()void releaseKeyboard ()bool isUpdatesEnabled () constvirtual bool close ( bool alsoDelete )bool isVisible () constbool isVisibleTo ( QWidget * ancestor ) constbool isVisibleToTLW () const— obsolete 🫠QRect visibleRect () const— obsolete 🫠bool isHidden () constbool isShown () constbool isMinimized () constbool isMaximized () constbool isFullScreen () constuint windowState () constvoid setWindowState ( uint windowState )virtual QSize sizeHint () constvirtual QSize minimumSizeHint () constvirtual QSizePolicy sizePolicy () constvirtual void setSizePolicy ( QSizePolicy )void setSizePolicy ( QSizePolicy::SizeType hor, QSizePolicy::SizeType ver, bool hfw = FALSE )virtual int heightForWidth ( int w ) constQRegion clipRegion () constQLayout * layout () constvoid updateGeometry ()virtual void reparent ( QWidget * parent, WFlags f, const QPoint & p, bool showIt = FALSE )void reparent ( QWidget * parent, const QPoint & p, bool showIt = FALSE )void recreate ( QWidget * parent, WFlags f, const QPoint & p, bool showIt = FALSE )— obsolete 🫠void erase ()void erase ( int x, int y, int w, int h )void erase ( const QRect & r )void erase ( const QRegion & reg )void scroll ( int dx, int dy )void scroll ( int dx, int dy, const QRect & r )void drawText ( int x, int y, const QString & str )void drawText ( const QPoint & pos, const QString & str )QWidget * focusWidget () constQRect microFocusHint () constbool acceptDrops () constvirtual void setAcceptDrops ( bool on )virtual void setAutoMask ( bool )bool autoMask () constenum BackgroundOrigin { WidgetOrigin, ParentOrigin, WindowOrigin, AncestorOrigin }virtual void setBackgroundOrigin ( BackgroundOrigin )BackgroundOrigin backgroundOrigin () constvirtual bool customWhatsThis () constQWidget * parentWidget ( bool sameWindow = FALSE ) constWFlags testWFlags ( WFlags f ) constQWidget * childAt ( int x, int y, bool includeThis = FALSE ) constQWidget * childAt ( const QPoint & p, bool includeThis = FALSE ) constvoid setWindowOpacity ( double level )double windowOpacity () constvoid setPalette ( const QPalette & p, bool )— obsolete 🫠void setFont ( const QFont & f, bool )— obsolete 🫠
🎀 Public Slots 🎀
virtual void setEnabled ( bool )void setDisabled ( bool disable )virtual void setCaption ( const QString & )virtual void setIcon ( const QPixmap & )virtual void setIconText ( const QString & )virtual void setMouseTracking ( bool enable )virtual void setFocus ()void clearFocus ()virtual void setUpdatesEnabled ( bool enable )void update ()void update ( int x, int y, int w, int h )void update ( const QRect & r )void repaint ()void repaint ( bool erase )void repaint ( int x, int y, int w, int h, bool erase = TRUE )void repaint ( const QRect & r, bool erase = TRUE )void repaint ( const QRegion & reg, bool erase = TRUE )virtual void show ()virtual void hide ()void setShown ( bool show )void setHidden ( bool hide )void iconify ()— obsolete 🫠virtual void showMinimized ()virtual void showMaximized ()void showFullScreen ()virtual void showNormal ()virtual void polish ()void constPolish () constbool close ()void raise ()void lower ()void stackUnder ( QWidget * w )virtual void move ( int x, int y )void move ( const QPoint & )virtual void resize ( int w, int h )void resize ( const QSize & )virtual void setGeometry ( int x, int y, int w, int h )virtual void setGeometry ( const QRect & )virtual void adjustSize ()
👑 Static Public Members 👑
void setTabOrder ( QWidget * first, QWidget * second )QWidget * mouseGrabber ()QWidget * keyboardGrabber ()QWidget * find ( WId id )
✨ Properties ✨
okay bestie, here's the whole property roster — every single one, no skips, no cap. 💅
bool acceptDrops— whether drop events are enabled for this widget. like, are we accepting drops or not? 🫳bool autoMask— whether the auto mask feature is enabled for the widget. mask on, mask off, mystery. 🎭QBrush backgroundBrush— the widget's background brush. read-only, so look but don't touch. 🖌️BackgroundMode backgroundMode— the color role used for painting the background of the widget. it's giving palette energy. 🎨BackgroundOrigin backgroundOrigin— the origin of the widget's background. where does the bg even come from? 🌅QSize baseSize— the base size of the widget. the O.G. size, if you will. 📏QString caption— the window caption (title). the name on the window, the whole identity. 🪟QRect childrenRect— the bounding rectangle of the widget's children. read-only. where the kids live. 🧸QRegion childrenRegion— the combined region occupied by the widget's children. read-only. the kids' combined territory. 🗺️QColorGroup colorGroup— the current color group of the widget palette. read-only. color mood, locked in. 🌈QCursor cursor— the cursor shape for this widget. pointer aesthetics, slay. 🖱️bool customWhatsThis— whether the widget wants to handle What's This help manually. read-only. DIY help vibe. ❓bool enabled— whether the widget is enabled. can you click it? yes/no. 🔛bool focus— whether this widget (or its focus proxy) has the keyboard input focus. read-only. keyboard attention, who has it? ⌨️bool focusEnabled— whether the widget accepts keyboard focus. read-only. is keyboard focus welcome here? 💌FocusPolicy focusPolicy— the way the widget accepts keyboard focus. the focus rules, the policy, the law. ⚖️QFont font— the font currently set for the widget. typography moment. 🔤QRect frameGeometry— geometry of the widget relative to its parent including any window frame. read-only. frame included, bestie. 🖼️QSize frameSize— the size of the widget including any window frame. read-only. frame size, no cap. 📐bool fullScreen— whether the widget is full screen. read-only. full screen or not? 🌌QRect geometry— the geometry of the widget relative to its parent and excluding the window frame. no frame, just vibes. 📦int height— the height of the widget excluding any window frame. read-only. how tall? 📏bool hidden— whether the widget is explicitly hidden. hidden, like my feelings. 🙈QPixmap icon— the widget's icon. the little pic, the brand. 🖼️QString iconText— the widget's icon text. text for the icon, iconic. 🏷️bool inputMethodEnabled— enables or disables the use of input methods for this widget. IME on/off, periodt. ⌨️bool isActiveWindow— whether this widget is the active window. read-only. main character window? 👑bool isDesktop— whether the widget is a desktop widget, i.e. represents the desktop. read-only. it's giving desktop realness. 🖥️bool isDialog— whether the widget is a dialog widget. read-only. dialog or not? 💬bool isModal— whether the widget is a modal widget. read-only. modal, so you're stuck with it. 🚧bool isPopup— whether the widget is a popup widget. read-only. popup princess. 🎈bool isTopLevel— whether the widget is a top-level widget. read-only. top-tier, literally. 🔝bool maximized— whether this widget is maximized. read-only. maxed out. 🪟int maximumHeight— the widget's maximum height. ceiling, but vertical. 📈QSize maximumSize— the widget's maximum size. the biggest it can be. 🐘int maximumWidth— the widget's maximum width. widest allowed. ↔️QRect microFocusHint— the currently set micro focus hint for this widget. read-only. tiny focus hint, big deal. 🔍bool minimized— whether this widget is minimized (iconified). read-only. minimized, iconified, same vibe. 🗕️int minimumHeight— the widget's minimum height. floor, but vertical. 📉QSize minimumSize— the widget's minimum size. the smallest it can be. 🐜QSize minimumSizeHint— the recommended minimum size for the widget. read-only. a suggestion, but make it cute. 💡int minimumWidth— the widget's minimum width. narrowest allowed. ↔️bool mouseTracking— whether mouse tracking is enabled for the widget. is the mouse being watched? 👀bool ownCursor— whether the widget uses its own cursor. read-only. does it have its own cursor? 💅bool ownFont— whether the widget uses its own font. read-only. font independence. 🔤bool ownPalette— whether the widget uses its own palette. read-only. palette independence. 🎨QPalette palette— the widget's palette. the color story. 🌈QColor paletteBackgroundColor— the background color of the widget. bg color, slay. 🎨QPixmap paletteBackgroundPixmap— the background pixmap of the widget. bg image moment. 🖼️QColor paletteForegroundColor— the foreground color of the widget. fg color, the text vibe. 🖍️QPoint pos— the position of the widget within its parent widget. where it's at. 📍QRect rect— the internal geometry of the widget excluding any window frame. read-only. internal rect, no frame. 📦bool shown— whether the widget is shown. shown or not? 👁️QSize size— the size of the widget excluding any window frame. size without the frame. 📐QSize sizeHint— the recommended size for the widget. read-only. the size it wants to be. 💖QSize sizeIncrement— the size increment of the widget. how it steps up in size. 🪜QSizePolicy sizePolicy— the default layout behavior of the widget. layout personality. 🧩bool underMouse— whether the widget is under the mouse cursor. read-only. is the mouse hovering? 🐭bool updatesEnabled— whether updates are enabled. updates on/off. 🔄bool visible— whether the widget is visible. read-only. can you see it? 👀QRect visibleRect— the visible rectangle. read-only and obsolete. it's giving legacy, bestie. 👵int width— the width of the widget excluding any window frame. read-only. how wide? ↔️double windowOpacity— the level of opacity for the window. see-through level. 🫥int x— the x coordinate of the widget relative to its parent including any window frame. read-only. x marks the spot. ➡️int y— the y coordinate of the widget relative to its parent and including any window frame. read-only. y though. ⬇️
🛡️ Protected Members 🛡️
these are the protected hooks, bestie — all virtual, all iconic, all exactly as written. no changing the signatures, periodt. 💅
virtual bool event ( QEvent * e )virtual void mousePressEvent ( QMouseEvent * e )virtual void mouseReleaseEvent ( QMouseEvent * e )virtual void mouseDoubleClickEvent ( QMouseEvent * e )virtual void mouseMoveEvent ( QMouseEvent * e )virtual void wheelEvent ( QWheelEvent * e )virtual void keyPressEvent ( QKeyEvent * e )virtual void keyReleaseEvent ( QKeyEvent * e )virtual void focusInEvent ( QFocusEvent * )virtual void focusOutEvent ( QFocusEvent * )virtual void enterEvent ( QEvent * )virtual void leaveEvent ( QEvent * )virtual void paintEvent ( QPaintEvent * )virtual void moveEvent ( QMoveEvent * )virtual void resizeEvent ( QResizeEvent * )virtual void closeEvent ( QCloseEvent * e )virtual void contextMenuEvent ( QContextMenuEvent * e )virtual void imStartEvent ( QIMEvent * e )virtual void imComposeEvent ( QIMEvent * e )virtual void imEndEvent ( QIMEvent * e )virtual void tabletEvent ( QTabletEvent * e )virtual void dragEnterEvent ( QDragEnterEvent * )virtual void dragMoveEvent ( QDragMoveEvent * )virtual void dragLeaveEvent ( QDragLeaveEvent * )virtual void dropEvent ( QDropEvent * )virtual void showEvent ( QShowEvent * )virtual void hideEvent ( QHideEvent * )virtual bool macEvent ( MSG * )virtual bool winEvent ( MSG * )virtual bool x11Event ( XEvent * )virtual bool qwsEvent ( QWSEvent * )virtual void updateMask ()virtual void styleChange ( QStyle & oldStyle )virtual void enabledChange ( bool oldEnabled )virtual void paletteChange ( const QPalette & oldPalette )virtual void fontChange ( const QFont & oldFont )virtual void windowActivationChange ( bool oldActive )virtual int metric ( int m ) constvoid resetInputContext ()virtual void create ( WId window = 0, bool initializeWindow = TRUE, bool destroyOldWindow = TRUE )virtual void destroy ( bool destroyWindow = TRUE, bool destroySubWindows = TRUE )WFlags getWFlags () constvirtual void setWFlags ( WFlags f )void clearWFlags ( WFlags f )virtual bool focusNextPrevChild ( bool next )QFocusData * focusData ()virtual void setKeyCompression ( bool compress )virtual void setMicroFocusHint ( int x, int y, int width, int height, bool text = TRUE, QFont * f = 0 )
💖 DESCRIPTION 💖
okay so, QWidget is the base class of all user interface objects. THE blueprint. the origin. the mother of all widgets, honestly. 👑
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. so if something's covering you, you're clipped, bestie. ✂️
A widget that isn't embedded in a parent widget is called a top-level widget. usually, top-level widgets are windows with a frame and a title bar (although it is also possible to create top-level widgets without such decoration if suitable widget flags are used). in Qt, QMainWindow and the various subclasses of QDialog are the most common top-level windows. 🪟
A widget without a parent widget is always a top-level widget. no parent, no problem. 🫶
Non-top-level widgets are child widgets. these are child windows in their parent widgets. you cannot usually distinguish a child widget from its parent visually. most other widgets in Qt are useful only as child widgets. (it is possible to make, say, a button into a top-level widget, but most people prefer to put their buttons inside other widgets, e.g. QDialog.) so like, yes you can make a button a top-level, but why would you? put it in a QDialog, bestie. 🎀
If you want to use a QWidget to hold child widgets you will probably want to add a layout to the parent QWidget. (See Layouts.) layout it out, periodt. 📐
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 QPushButton, QListBox and QTabDialog, etc. so yeah, QWidget is the base, but the subclasses are the ones doing the actual performing. 💅
🫶 Groups of functions: 🫶
<center>.nf
</center>
Every widget's constructor accepts two or three standard arguments, bestie, and here they are:
QWidget *parent = 0is the parent of the new widget. If it's0(the default, no cap), your new widget is a top-level window. If it's not0, it becomes a child of parent and gets constrained by parent's geometry — unless you specifyWType_TopLevelas a widget flag. 💅const char *name = 0is the widget name of the new widget. You can access it usingname(). The widget name is little used by programmers, but it's lowkey super useful with GUI builders like Qt Designer — you can name a widget in Qt Designer and thenconnect()to it using that name in your code. ThedumpObjectTree()debugging function also uses it. 🎀WFlags f = 0(where available) sets the widget flags. The default is suitable for almost all widgets, but to get, for example, a top-level widget without a window system frame, you must use special flags. ✨
The tictac/tictac.cpp example program is a good example of a simple widget. It contains a few event handlers (as all widgets must), a few custom routines that are specific to it (as all useful widgets do), and has a few children and connections. Everything it does is done in response to an event — this is by far the most common way to design GUI applications. 🦋
You will need to supply the content for your widgets yourself, but here is a brief run-down of the events, starting with the most common ones:
paintEvent()— called whenever the widget needs to be repainted. Every widget which displays output must implement it, and it is wise not to paint on the screen outsidepaintEvent(). 🎨resizeEvent()— called when the widget has been resized. 📐mousePressEvent()— called when a mouse button is pressed. There are six mouse-related events, but the mouse press and mouse release events are by far the most important. A widget receives mouse press events when the mouse is inside it, or when it has grabbed the mouse usinggrabMouse(). 🖱️mouseReleaseEvent()— called when a mouse button is released. A widget receives mouse release events when it has received the corresponding mouse press event. This means that if the user presses the mouse inside your widget, then drags the mouse to somewhere else, then releases, your widget receives the release event. There is one exception: if a popup menu appears while the mouse button is held down, this popup immediately steals the mouse events. 😤mouseDoubleClickEvent()— not quite as obvious as it might seem. If the user double-clicks, the widget receives a mouse press event (perhaps a mouse move event or two if they don't hold the mouse quite steady), a mouse release event and finally this event. It is not possible to distinguish a click from a double click until you've seen whether the second click arrives. (This is one reason why most GUI books recommend that double clicks be an extension of single clicks, rather than trigger a different action.) 💀
If your widget only contains child widgets, you probably do not need to implement any event handlers. If you want to detect a mouse click in a child widget, call the child's hasMouse() function inside the parent widget's mousePressEvent(). 👑
Widgets that accept keyboard input need to reimplement a few more event handlers:
keyPressEvent()— called whenever a key is pressed, and again when a key has been held down long enough for it to auto-repeat. Note that theTabandShift+Tabkeys are only passed to the widget if they are not used by the focus-change mechanisms. To force those keys to be processed by your widget, you must reimplementQWidget::event(). ⌨️focusInEvent()— called when the widget gains keyboard focus (assuming you have calledsetFocusPolicy()). Well written widgets indicate that they own the keyboard focus in a clear but discreet way. 🌟focusOutEvent()— called when the widget loses keyboard focus. 😭
Some widgets will also need to reimplement some of the less common event handlers:
mouseMoveEvent()— called whenever the mouse moves while a button is held down. This is useful for, for example, dragging. If you callsetMouseTracking(TRUE), you get mouse move events even when no buttons are held down. (Note that applications which make use of mouse tracking are often not very useful on low-bandwidth X connections.) (See also the drag and drop information.) 🖱️keyReleaseEvent()— called whenever a key is released, and also while it is held down if the key is auto-repeating. In that case the widget receives a key release event and immediately a key press event for every repeat. Note that theTabandShift+Tabkeys are only passed to the widget if they are not used by the focus-change mechanisms. To force those keys to be processed by your widget, you must reimplementQWidget::event(). 🔁wheelEvent()— called whenever the user turns the mouse wheel while the widget has the focus. 🎡enterEvent()— called when the mouse enters the widget's screen space. (This excludes screen space owned by any children of the widget.) 🐭leaveEvent()— called when the mouse leaves the widget's screen space. 👋moveEvent()— called when the widget has been moved relative to its parent. 📦closeEvent()— called when the user closes the widget (or whenclose()is called). 🚪
There are also some rather obscure events. They are listed in qevent.h and you need to reimplement event() to handle them. The default implementation of event() handles Tab and Shift+Tab (to move the keyboard focus), and passes on most other events to one of the more specialized handlers above. 🌈
When implementing a widget, there are a few more things to consider.
In the constructor, be sure to set up your member variables early on, before there's any chance that you might receive an event. 🧠
It is almost always useful to reimplement sizeHint() and to set the correct size policy with setSizePolicy(), so users of your class can set up layout management more easily. A size policy lets you supply good defaults for the layout management handling, so that other widgets can contain and manage yours easily. sizeHint() indicates a "good" size for the widget. 📏
If your widget is a top-level window, setCaption() and setIcon() set the title bar and icon respectively. 🖼️
See also QEvent, QPainter, QGridLayout, QBoxLayout, and Abstract Widget Classes.
🫶 Member Type Documentation 🫶
QWidget::BackgroundOrigin
This enum defines the origin used to draw a widget's background pixmap.
The pixmap is drawn using the:
QWidget::WidgetOrigin— widget's coordinate system.QWidget::ParentOrigin— parent's coordinate system.QWidget::WindowOrigin— top-level window's coordinate system.QWidget::AncestorOrigin— same origin as the parent uses.
QWidget::FocusPolicy
This enum type defines the various policies a widget can have with respect to acquiring keyboard focus.
QWidget::TabFocus— the widget accepts focus by tabbing.QWidget::ClickFocus— the widget accepts focus by clicking.QWidget::StrongFocus— the widget accepts focus by both tabbing and clicking. On Mac OS X this will also be indicate that the widget accepts tab focus when in 'Text/List focus mode'.QWidget::WheelFocus— likeStrongFocusplus the widget accepts focus by using the mouse wheel.QWidget::NoFocus— the widget does not accept focus.
💅 MEMBER FUNCTION DOCUMENTATION 💅
✨ explicit QWidget::QWidget ( QWidget * parent = 0, const char * name = 0, WFlags f = 0 ) ✨
Constructs a widget which is a child of parent, with the name name and widget flags set to f.
If parent is 0, the new widget becomes a top-level window. If parent is another widget, this widget becomes a child window inside parent. The new widget is deleted when its parent is deleted.
The name is sent to the QObject constructor.
The widget flags argument, f, is normally 0, but it can be set to customize the window frame of a top-level widget (i.e. parent must be 0). To customize the frame, set the WStyle_Customize flag OR'ed with any of the Qt::WidgetFlags.
If you add a child widget to an already visible widget you must explicitly show the child to make it visible.
Note that the X11 version of Qt may not be able to deliver all combinations of style flags on all systems. This is because on X11, Qt can only ask the window manager, and the window manager can override the application's settings. On Windows, Qt can set whatever flags you want.
Example:
QLabel *splashScreen = new QLabel( 0, "mySplashScreen",
WStyle_Customize | WStyle_Splash );
💀 QWidget::~QWidget () 💀
Destroys the widget.
All this widget's children are deleted first. The application exits if this widget is the main widget.
bool QWidget::acceptDrops () const
Returns TRUE if drop events are enabled for this widget; otherwise returns FALSE. See the "acceptDrops" property for details.
void QWidget::adjustSize () [virtual slot]
Adjusts the size of the widget to fit the contents.
Uses sizeHint() if valid (i.e if the size hint's width and height are >= 0), otherwise sets the size to the children rectangle (the union of all child widget geometries).
See also sizeHint and childrenRect.
Example: xform/xform.cpp.
Reimplemented in QMessageBox.
bool QWidget::autoMask () const
Returns TRUE if the auto mask feature is enabled for the widget; otherwise returns FALSE. See the "autoMask" property for details.
const QBrush & QWidget::backgroundBrush () const
Returns the widget's background brush. See the "backgroundBrush" property for details.
const QColor & QWidget::backgroundColor () const
This function is obsolete. It is provided to keep old source working. We strongly advise against using it in new code. Use paletteBackgroundColor() or eraseColor() instead.
BackgroundMode QWidget::backgroundMode () const
Returns the color role used for painting the background of the widget. See the "backgroundMode" property for details.
BackgroundOrigin QWidget::backgroundOrigin () const
Returns the origin of the widget's background. See the "backgroundOrigin" property for details.
const QPixmap * QWidget::backgroundPixmap () const
This function is obsolete. It is provided to keep old source working. We strongly advise against using it in new code. Use paletteBackgroundPixmap() or erasePixmap() instead.
Examples:
QSize QWidget::baseSize () const
Returns the base size of the widget. See the "baseSize" property for details.
QString QWidget::caption () const
Returns the window caption (title). See the "caption" property for details.
QWidget * QWidget::childAt ( int x, int y, bool includeThis = FALSE ) const
ok so bestie, you wanna know which lil widget is literally at a pixel? 👀 This hands you back the visible child widget sitting at pixel position (x, y) — and that's in the widget's own coordinate system, not global, so don't get it twisted 🦋.
And if includeThis is TRUE and there's no child visible at (x, y)? Then the widget itself gets returned. self-love moment, honestly 💅.
QWidget * QWidget::childAt ( const QPoint & p, bool includeThis = FALSE ) const
This is an overloaded member function, provided for convenience 🎀. It behaves essentially like the above function.
Returns the visible child widget at point p in the widget's own coordinate system.
If includeThis is TRUE, and there is no child visible at p, the widget itself is returned. same energy as before, just with a QPoint instead of two ints ✨.
QRect QWidget::childrenRect () const
Returns the bounding rectangle of the widget's children 📦. See the "childrenRect" property for the deets.
QRegion QWidget::childrenRegion () const
Returns the combined region occupied by the widget's children 🌈. See the "childrenRegion" property for the deets.
void QWidget::clearFocus () [slot]
Takes keyboard input focus away from the widget. bye bestie 👋💖.
If the widget has active focus, a focus out event is sent to this widget to tell it that it is about to lose the focus. Rude? Maybe. Necessary? Absolutely.
Heads up: this widget must enable focus setting in order to get the keyboard input focus in the first place, i.e. it must call setFocusPolicy() 🫶.
See also: focus, setFocus(), focusInEvent(), focusOutEvent(), focusPolicy, and QApplication::focusWidget().
void QWidget::clearMask ()
Removes any mask set by setMask() 💅. unmasking era, we love to see it.
See also: setMask().
void QWidget::clearWFlags ( WFlags f ) [protected]
Clears the widget flags f 🧹.
Widget flags are a combination of Qt::WidgetFlags.
See also: testWFlags(), getWFlags(), and setWFlags().
QRegion QWidget::clipRegion () const
Returns the unobscured region where paint events can occur 🎨.
For visible widgets, this is an approximation of the area not covered by other widgets; otherwise, this is an empty region. (empty region = nobody can see you, the ultimate introvert vibe 😭.)
The repaint() function calls this function if necessary, so in general you do not need to call it yourself. let the framework cook 🔥.
bool QWidget::close () [slot]
Closes this widget 🚪✨. Returns TRUE if the widget was closed; otherwise returns FALSE.
First it sends the widget a QCloseEvent. The widget is hidden if it accepts the close event. The default implementation of QWidget::closeEvent() accepts the close event — so by default, it's slay and it goes through.
The QApplication::lastWindowClosed() signal is emitted when the last visible top level widget is closed 👑.
Examples:
bool QWidget::close ( bool alsoDelete ) [virtual]
This is an overloaded member function, provided for convenience 🎀. It behaves essentially like the above function.
Closes this widget. Returns TRUE if the widget was closed; otherwise returns FALSE.
If alsoDelete is TRUE or the widget has the WDestructiveClose widget flag, the widget is also deleted 💀. The widget can prevent itself from being closed by rejecting the QCloseEvent it gets. A close events is delivered to the widget no matter if the widget is visible or not. (yes, even when it's hidden. it's getting that notification fr fr.)
The QApplication::lastWindowClosed() signal is emitted when the last visible top level widget is closed.
Note that closing the QApplication::mainWidget() terminates the application 😭 that's not a vibe, that's the whole program.
See also: closeEvent(), QCloseEvent, hide(), QApplication::quit(), QApplication::setMainWidget(), and QApplication::lastWindowClosed().
void QWidget::closeEvent ( QCloseEvent * e ) [virtual protected]
This event handler, for event e, can be reimplemented in a subclass to receive widget close events 🫶.
The default implementation calls e->accept(), which hides this widget. See the QCloseEvent documentation for more details.
See also: event(), hide(), close(), and QCloseEvent.
Examples:
const QColorGroup & QWidget::colorGroup () const
Returns the current color group of the widget palette 🎨💖. See the "colorGroup" property for the deets.
void QWidget::constPolish () const [slot]
Ensures that the widget is properly initialized by calling polish() ✨. get that glow-up in.
Call constPolish() from functions like sizeHint() that depends on the widget being initialized, and that may be called before show().
Warning: Do not call constPolish() on a widget from inside that widget's constructor 🚫😭. that's a no-no, bestie, don't do it.
See also: polish().
void QWidget::contextMenuEvent ( QContextMenuEvent * e ) [virtual protected]
This event handler, for event e, can be reimplemented in a subclass to receive widget context menu events 🖱️.
The default implementation calls e->ignore(), which rejects the context event. See the QContextMenuEvent documentation for more details.
See also: event() and QContextMenuEvent.
Example: menu/menu.cpp.
void QWidget::create ( WId window = 0, bool initializeWindow = TRUE, bool destroyOldWindow = TRUE ) [virtual protected]
Creates a new widget window if window is 0, otherwise sets the widget's window to window 🪟✨.
Initializes the window (sets the geometry etc.) if initializeWindow is TRUE. If initializeWindow is FALSE, no initialization is performed. This parameter only makes sense if window is a valid window.
Destroys the old window if destroyOldWindow is TRUE. If destroyOldWindow is FALSE, you are responsible for destroying the window yourself (using platform native code) 🫡. your window, your problem.
The QWidget constructor calls create(0,TRUE,TRUE) to create a window for this widget.
const QCursor & QWidget::cursor () const
Returns the cursor shape for this widget 🖱️💅. See the "cursor" property for the deets.
bool QWidget::customWhatsThis () const [virtual]
Returns TRUE if the widget wants to handle What's This help manually; otherwise returns FALSE ❓✨. See the "customWhatsThis" property for the deets.
void QWidget::destroy ( bool destroyWindow = TRUE, bool destroySubWindows = TRUE ) [virtual protected]
Frees up window system resources 🧹💀. Destroys the widget window if destroyWindow is TRUE.
destroy() calls itself recursively for all the child widgets, passing destroySubWindows for the destroyWindow parameter. To have more control over destruction of subwidgets, destroy subwidgets selectively first 🎯.
This function is usually called from the QWidget destructor.
void QWidget::dragEnterEvent ( QDragEnterEvent * ) [virtual protected]
This event handler is called when a drag is in progress and the mouse enters this widget 🖱️🎀.
See the Drag-and-drop documentation for an overview of how to provide drag-and-drop in your application.
See also: QTextDrag, QImageDrag, and QDragEnterEvent.
Example: iconview/simple_dd/main.cpp.
void QWidget::dragLeaveEvent ( QDragLeaveEvent * ) [virtual protected]
This event handler is called when a drag is in progress and the mouse leaves this widget 👋🖱️.
See the Drag-and-drop documentation for an overview of how to provide drag-and-drop in your application.
See also: QTextDrag, QImageDrag, and QDragLeaveEvent.
void QWidget::dragMoveEvent ( QDragMoveEvent * ) [virtual protected]
This event handler is called when a drag is in progress and the mouse enters this widget, and whenever it moves within the widget 🔥🖱️. it's giving constant surveillance, but make it drag-and-drop.
See the Drag-and-drop documentation for an overview of how to provide drag-and-drop in your application.
See also: QTextDrag, QImageDrag, and QDragMoveEvent.
void QWidget::drawText ( int x, int y, const QString & str )
Draws the string str at position (x, y) ✍️💖.
The y position is the base line position of the text. The text is drawn using the default font and the default foreground color.
This function is provided for convenience. You will generally get more flexible results and often higher speed by using a painter instead 🎨.
See also: font, foregroundColor(), and QPainter::drawText().
void QWidget::drawText ( const QPoint & pos, const QString & str )
This is an overloaded member function, provided for convenience 🎀. It behaves essentially like the above function.
Draws the string str at position pos.
void QWidget::dropEvent ( QDropEvent * ) [virtual protected]
This event handler is called when the drag is dropped on this widget 🫳✨.
See the Drag-and-drop documentation for an overview of how to provide drag-and-drop in your application.
See also: QTextDrag, QImageDrag, and QDropEvent.
Example: iconview/simple_dd/main.cpp.
void QWidget::enabledChange ( bool oldEnabled ) [virtual protected]
This virtual function is called from setEnabled() 🔔. oldEnabled is the previous setting; you can get the new setting from isEnabled().
Reimplement this function if your widget needs to know when it becomes enabled or disabled. You will almost certainly need to update the widget using update() 😌.
The default implementation repaints the visible part of the widget.
See also: enabled, enabled, repaint(), update(), and clipRegion().
void QWidget::enterEvent ( QEvent * ) [virtual protected]
This event handler can be reimplemented in a subclass to receive widget enter events 🚪✨.
An event is sent to the widget when the mouse cursor enters the widget.
See also: leaveEvent(), mouseMoveEvent(), and event().
void QWidget::erase ( int x, int y, int w, int h )
Erases the specified area (x, y, w, h) in the widget without generating a paint event 🧽👀. no repaint, just vibes erased.
If w is negative, it is replaced with width() - x. If h is negative, it is replaced with height() - y.
Child widgets are not affected 🙅.
See also: repaint().
void QWidget::erase ()
This is an overloaded member function, provided for convenience 🎀. It behaves essentially like the above function.
This version erases the entire widget. all of it. gone. poof 💨.
void QWidget::erase ( const QRect & r )
This is an overloaded member function, provided for convenience 🎀. It behaves essentially like the above function.
Erases the specified area r in the widget without generating a paint event.
void QWidget::erase ( const QRegion & reg )
This is an overloaded member function, provided for convenience 🎀. It behaves essentially like the above function.
Erases the area defined by reg, without generating a paint event.
Child widgets are not affected 🙅💖.
const QColor & QWidget::eraseColor () const
Returns the erase color of the widget 🎨🧽.
See also: setEraseColor(), setErasePixmap(), and backgroundColor().
const QPixmap * QWidget::erasePixmap () const
Returns the widget's erase pixmap 🖼️✨.
See also: setErasePixmap() and eraseColor().
💥 bool QWidget::event ( QEvent * e ) [virtual protected]
okay bestie this is THE main event handler — it handles the event e. you can reimplement this in a subclass, but fr fr the devs recommend you just use one of the specialized event handlers instead (way less drama, way more vibes). ✨
so what happens: the main event handler first passes an event through all the event filters that have been installed. if none of the filters intercept it, it calls one of the specialized event handlers. simple as that. 💅
key press and release events get treated differently from everything else, no cap. event() checks for Tab and Shift+Tab and tries to move the focus appropriately. and if there's no widget to move the focus to (or the key press isn't Tab or Shift+Tab), event() calls keyPressEvent().
this function returns TRUE if it's able to pass the event over to someone (like, someone actually wanted the event 👀); otherwise it returns FALSE.
See also closeEvent(), focusInEvent(), focusOutEvent(), enterEvent(), keyPressEvent(), keyReleaseEvent(), leaveEvent(), mouseDoubleClickEvent(), mouseMoveEvent(), mousePressEvent(), mouseReleaseEvent(), moveEvent(), paintEvent(), resizeEvent(), QObject::event(), and QObject::timerEvent().
Reimplemented from QObject.
🔎 QWidget * QWidget::find ( WId id ) [static]
returns a pointer to the widget with the window identifer/handle id. 🫶
the window identifier type depends on the underlying window system, so peek at qwindowdefs.h for the actual definition. and if there's no widget with this identifier, 0 gets returned. (that's the "not me, i'm not here" result 💀)
🎯 QFocusData * QWidget::focusData () [protected]
returns the focus data for this widget's top-level widget.
focus data always belongs to the top-level widget. the focus data list contains all the widgets in this top-level widget that can accept focus, in tab order. an iterator points to the current focus widget (focusWidget() returns a pointer to this widget, bestie).
this info is genuinely useful for implementing advanced versions of focusNextPrevChild(). 🔥
🌟 void QWidget::focusInEvent ( QFocusEvent * ) [virtual protected]
this event handler can be reimplemented in a subclass to receive keyboard focus events (aka focus received) for the widget.
a widget normally has to setFocusPolicy() to something other than NoFocus in order to receive focus events. (quick note tho: the application programmer can call setFocus() on any widget, even those that don't normally accept focus. main character behavior, honestly. 👑)
the default implementation updates the widget (except for toplevel widgets that don't specify a focusPolicy() ). it also calls setMicroFocusHint(), hinting any system-specific input tools about the focus of the user's attention.
See also focusOutEvent(), focusPolicy, keyPressEvent(), keyReleaseEvent(), event(), and QFocusEvent.
🧭 bool QWidget::focusNextPrevChild ( bool next ) [virtual protected]
finds a new widget to give the keyboard focus to, as appropriate for Tab and Shift+Tab, and returns TRUE if is can find a new widget and FALSE if it can't,
if next is TRUE, this function searches "forwards", if next is FALSE, it searches "backwards".
sometimes you'll lowkey wanna reimplement this. for example, a web browser might reimplement it to move its "current active link" forwards or backwards, and call QWidget::focusNextPrevChild() only when it reaches the last or first link on the "page". 🦋
child widgets call focusNextPrevChild() on their parent widgets, but only the top-level widget decides where to redirect focus. so by overriding this method for an object, you gain control of focus traversal for all child widgets. iconic.
Warning:QScrollViewuses it own logic for this function, which does the right thing in most cases. But if you are using aQScrollViewand want complete control of the focus chain you'll need to overrideQScrollView::focusNextPrevChild()and your top-level widgets'focusNextPrevChild()functions. 😤
See also focusData().
🫧 void QWidget::focusOutEvent ( QFocusEvent * ) [virtual protected]
this event handler can be reimplemented in a subclass to receive keyboard focus events (aka focus lost) for the widget. (the sad goodbye event, but make it technical 💔)
a widget normally has to setFocusPolicy() to something other than NoFocus in order to receive focus events. (again, note that the application programmer can call setFocus() on any widget, even those that do not normally accept focus.)
the default implementation updates the widget (except for toplevel widgets that do not specify a focusPolicy() ). it also calls setMicroFocusHint(), hinting any system-specific input tools about the focus of the user's attention.
See also focusInEvent(), focusPolicy, keyPressEvent(), keyReleaseEvent(), event(), and QFocusEvent.
Example: qmag/qmag.cpp.
✨ FocusPolicy QWidget::focusPolicy () const
returns the way the widget accepts keyboard focus. see the "focusPolicy" property for the details, bestie. 💖
🔮 QWidget * QWidget::focusProxy () const
returns the focus proxy, or 0 if there is no focus proxy.
See also setFocusProxy().
👀 QWidget * QWidget::focusWidget () const
returns the focus widget in this widget's window. and ngl this is not the same as QApplication::focusWidget(), which returns the focus widget in the currently active window. two different things, don't mix them up. 🎀
🌈 QFont QWidget::font () const
returns the font currently set for the widget. see the "font" property for details.
💅 void QWidget::fontChange ( const QFont & oldFont ) [virtual protected]
this virtual function is called from setFont(). oldFont is the previous font; you can get the new font from font().
reimplement this function if your widget needs to know when its font changes. you will almost certainly need to update the widget using update(). (glow up requires a refresh, periodt. ✨)
the default implementation updates the widget including its geometry.
See also font, font, update(), and updateGeometry().
🧚 QFontInfo QWidget::fontInfo () const
returns the font info for the widget's current font. equivalent to QFontInto(widget->font()).
See also font, fontMetrics(), and font.
🍓 QFontMetrics QWidget::fontMetrics () const
returns the font metrics for the widget's current font. equivalent to QFontMetrics(widget->font()).
See also font, fontInfo(), and font.
Examples:
🎀 const QColor & QWidget::foregroundColor () const
same as paletteForegroundColor(). that's it, that's the whole function. short and sweet. 💖
🖼️ QRect QWidget::frameGeometry () const
returns the geometry of the widget relative to its parent including any window frame. see the "frameGeometry" property for details.
📐 QSize QWidget::frameSize () const
returns the size of the widget including any window frame. see the "frameSize" property for details.
📏 const QRect & QWidget::geometry () const
returns the geometry of the widget relative to its parent and excluding the window frame. see the "geometry" property for details.
🚩 WFlags QWidget::getWFlags () const [protected]
returns the widget flags for this this widget.
widget flags are a combination of Qt::WidgetFlags.
See also testWFlags(), setWFlags(), and clearWFlags().
⌨️ void QWidget::grabKeyboard ()
grabs the keyboard input. 🫴
this widget reveives all keyboard events until releaseKeyboard() is called; other widgets get no keyboard events at all. mouse events are not affected. use grabMouse() if you want to grab that.
the focus widget is not affected, except that it doesn't receive any keyboard events. setFocus() moves the focus as usual, but the new focus widget receives keyboard events only after releaseKeyboard() is called.
if a different widget is currently grabbing keyboard input, that widget's grab is released first.
See also releaseKeyboard(), grabMouse(), releaseMouse(), and focusWidget().
🖱️ void QWidget::grabMouse ()
grabs the mouse input.
this widget receives all mouse events until releaseMouse() is called; other widgets get no mouse events at all. keyboard events are not affected. use grabKeyboard() if you want to grab that.
Warning: Bugs in mouse-grabbing applications very often lock the terminal. Use this function with extreme caution, and consider using the -nograb command line option while debugging. ⚠️ like fr, be careful.
it is almost never necessary to grab the mouse when using Qt, as Qt grabs and releases it sensibly. in particular, Qt grabs the mouse when a mouse button is pressed and keeps it until the last button is released.
note that only visible widgets can grab mouse input. if isVisible() returns FALSE for a widget, that widget cannot call grabMouse(). no visibility, no grabby. 🙈
See also releaseMouse(), grabKeyboard(), releaseKeyboard(), grabKeyboard(), and focusWidget().
🖱️ void QWidget::grabMouse ( const QCursor & cursor )
this is an overloaded member function, provided for convenience. it behaves essentially like the above function.
grabs the mouse input and changes the cursor shape.
the cursor will assume shape cursor (for as long as the mouse focus is grabbed) and this widget will be the only one to receive mouse events until releaseMouse() is called(). 👑
Warning: Grabbing the mouse might lock the terminal. ⚠️
See also releaseMouse(), grabKeyboard(), releaseKeyboard(), and cursor.
💜 bool QWidget::hasFocus () const
returns TRUE if this widget (or its focus proxy) has the keyboard input focus; otherwise returns FALSE. see the "focus" property for details.
🌸 bool QWidget::hasMouse () const
returns TRUE if the widget is under the mouse cursor; otherwise returns FALSE. see the "underMouse" property for details.
🦋 bool QWidget::hasMouseTracking () const
returns TRUE if mouse tracking is enabled for the widget; otherwise returns FALSE. see the "mouseTracking" property for details.
📊 int QWidget::height () const
returns the height of the widget excluding any window frame. see the "height" property for details.
🧮 int QWidget::heightForWidth ( int w ) const [virtual]
returns the preferred height for this widget, given the width w. the default implementation returns 0, indicating that the preferred height does not depend on the width.
Warning: Does not look at the widget's layout. 🙈
Reimplemented in QMenuBar and QTextEdit.
🙈 void QWidget::hide () [virtual slot]
hides the widget. poof. gone. ✨
you almost never have to reimplement this function. if you need to do something after a widget is hidden, use hideEvent() instead.
See also hideEvent(), hidden, show(), showMinimized(), visible, and close().
Examples:
Reimplemented in QMenuBar.
🌙 void QWidget::hideEvent ( QHideEvent * ) [virtual protected]
this event handler can be reimplemented in a subclass to receive widget hide events.
hide events are sent to widgets immediately after they have been hidden.
See also event() and QHideEvent.
Reimplemented in QScrollBar.
🖼️ const QPixmap * QWidget::icon () const
returns the widget's icon. see the "icon" property for details.
🏷️ QString QWidget::iconText () const
returns the widget's icon text. see the "iconText" property for details.
💀 void QWidget::iconify () [slot]
this function is obsolete. it is provided to keep old source working. we strongly advise against using it in new code. (it's giving legacy code energy, ngl. leave it in the past bestie. 🫶)
void QWidget::imComposeEvent ( QIMEvent * e ) [virtual protected]
okay so this is the event handler for event e, and bestie you can reimplement it in a subclass to catch Input Method composition events 🎹✨ This one fires when the user has entered some text using an Input Method.
The default implementation calls e->ignore(), which rejects the Input Method event. Rude but it's the default. Peep the QIMEvent docs for more deets.
See also event() and QIMEvent.
void QWidget::imEndEvent ( QIMEvent * e ) [virtual protected]
same energy, different moment 💅 Reimplement this in a subclass to receive Input Method composition events for event e. This one gets called when the user has finished inputting text via an Input Method. It's giving "ok we're done here".
The default implementation calls e->ignore(), which rejects the Input Method event. See the QIMEvent documentation for more details.
See also event() and QIMEvent.
void QWidget::imStartEvent ( QIMEvent * e ) [virtual protected]
the opening number 🎬 Reimplement in a subclass to receive Input Method composition events for event e. Called when the user begins entering text using an Input Method.
The default implementation calls e->ignore(), which rejects the Input Method event. See the QIMEvent documentation for more details.
See also event() and QIMEvent.
bool QWidget::isActiveWindow () const
Returns TRUE if this widget is the active window, otherwise FALSE. See the "isActiveWindow" property for details. 👑
bool QWidget::isDesktop () const
Returns TRUE if the widget is a desktop widget, i.e. it represents the desktop; otherwise FALSE. See the "isDesktop" property for details. 🖥️
bool QWidget::isDialog () const
Returns TRUE if the widget is a dialog widget; otherwise FALSE. See the "isDialog" property for details.
bool QWidget::isEnabled () const
Returns TRUE if the widget is enabled; otherwise FALSE. See the "enabled" property for details. ✨
bool QWidget::isEnabledTo ( QWidget * ancestor ) const
Returns TRUE if this widget would become enabled if ancestor is enabled; otherwise FALSE.
This is the case if neither the widget itself nor every parent up to but excluding ancestor has been explicitly disabled.
isEnabledTo(0) is equivalent to isEnabled().
See also enabled and enabled.
bool QWidget::isEnabledToTLW () const
⚠️ This function is obsolete. It is provided to keep old source working. We strongly advise against using it in new code.
This function is deprecated. It is equivalent to isEnabled().
bool QWidget::isFocusEnabled () const
Returns TRUE if the widget accepts keyboard focus; otherwise FALSE. See the "focusEnabled" property for details. ⌨️💖
bool QWidget::isFullScreen () const
Returns TRUE if the widget is full screen; otherwise FALSE. See the "fullScreen" property for details.
bool QWidget::isHidden () const
Returns TRUE if the widget is explicitly hidden; otherwise FALSE. See the "hidden" property for details. 🙈
bool QWidget::isInputMethodEnabled () const
Returns enables or disables the use of input methods for this widget. See the "inputMethodEnabled" property for details.
bool QWidget::isMaximized () const
Returns TRUE if this widget is maximized; otherwise FALSE. See the "maximized" property for details.
bool QWidget::isMinimized () const
Returns TRUE if this widget is minimized (iconified); otherwise FALSE. See the "minimized" property for details.
bool QWidget::isModal () const
Returns TRUE if the widget is a modal widget; otherwise FALSE. See the "isModal" property for details.
bool QWidget::isPopup () const
Returns TRUE if the widget is a popup widget; otherwise FALSE. See the "isPopup" property for details. 🎈
bool QWidget::isShown () const
Returns TRUE if the widget is shown; otherwise FALSE. See the "shown" property for details.
bool QWidget::isTopLevel () const
Returns TRUE if the widget is a top-level widget; otherwise FALSE. See the "isTopLevel" property for details.
bool QWidget::isUpdatesEnabled () const
Returns TRUE if updates are enabled; otherwise FALSE. See the "updatesEnabled" property for details. 🔄
bool QWidget::isVisible () const
Returns TRUE if the widget is visible; otherwise FALSE. See the "visible" property for details. 👀
bool QWidget::isVisibleTo ( QWidget * ancestor ) const
Returns TRUE if this widget would become visible if ancestor is shown; otherwise FALSE.
The TRUE case occurs if neither the widget itself nor any parent up to but excluding ancestor has been explicitly hidden.
This function will still return TRUE if the widget is obscured by other windows on the screen, but could be physically visible if it or they were to be moved.
isVisibleTo(0) is identical to isVisible().
See also show(), hide(), and visible.
bool QWidget::isVisibleToTLW () const
⚠️ This function is obsolete. It is provided to keep old source working. We strongly advise against using it in new code.
This function is deprecated. It is equivalent to isVisible().
void QWidget::keyPressEvent ( QKeyEvent * e ) [virtual protected]
okay keyboard girlies rise 🎹✨ This event handler, for event e, can be reimplemented in a subclass to receive key press events for the widget.
A widget must call setFocusPolicy() to accept focus initially and have focus in order to receive a key press event.
If you reimplement this handler, it is very important that you explicitly ignore the event if you do not understand it, so that the widget's parent can interpret it; otherwise, the event will be implicitly accepted. Like, top-level widgets can choose whether to accept or ignore unknown events because they have no parent widgets that could otherwise handle them, but it's good practice to explicitly ignore events to make widgets as reusable as possible. Periodt.
The default implementation closes popup widgets if the user presses Esc. Otherwise the event is ignored.
See also keyReleaseEvent(), QKeyEvent::ignore(), focusPolicy, focusInEvent(), focusOutEvent(), event(), and QKeyEvent.
Example: picture/picture.cpp.
Reimplemented in QLineEdit and QTextEdit.
void QWidget::keyReleaseEvent ( QKeyEvent * e ) [virtual protected]
the sequel 🔑 Reimplementable in a subclass to receive key release events for the widget, for event e.
A widget must accept focus initially and have focus in order to receive a key release event.
If you reimplement this handler, it is very important that you ignore() the release if you do not understand it, so that the widget's parent can interpret it.
The default implementation ignores the event.
See also keyPressEvent(), QKeyEvent::ignore(), focusPolicy, focusInEvent(), focusOutEvent(), event(), and QKeyEvent.
QWidget * QWidget::keyboardGrabber () [static]
Returns the widget that is currently grabbing the keyboard input. 🫳⌨️
If no widget in this application is currently grabbing the keyboard, 0 is returned.
See also grabMouse() and mouseGrabber().
QLayout * QWidget::layout () const
Returns the layout engine that manages the geometry of this widget's children. It's the backstage manager for all your little widgets fr fr 🎀
If the widget does not have a layout, layout() returns 0.
See also sizePolicy.
Examples:
void QWidget::leaveEvent ( QEvent * ) [virtual protected]
Reimplement this in a subclass to receive widget leave events. 👋
A leave event is sent to the widget when the mouse cursor leaves the widget.
See also enterEvent(), mouseMoveEvent(), and event().
void QWidget::lower () [slot]
Lowers the widget to the bottom of the parent widget's stack.
After this call the widget will be visually behind (and therefore obscured by) any overlapping sibling widgets. It's giving "not the main character today" 😭
See also raise() and stackUnder().
bool QWidget::macEvent ( MSG * ) [virtual protected]
This special event handler can be reimplemented in a subclass to receive native Macintosh events. 🍎
In your reimplementation of this function, if you want to stop the event being handled by Qt, return TRUE. If you return FALSE, this native event is passed back to Qt, which translates the event into a Qt event and sends it to the widget.
⚠️ Warning: This function is not portable.
See also QApplication::macEventFilter().
QPoint QWidget::mapFrom ( QWidget * parent, const QPoint & pos ) const
Translates the widget coordinate pos from the coordinate system of parent to this widget's coordinate system. The parent must not be 0 and must be a parent of the calling widget. 🗺️✨
See also mapTo(), mapFromParent(), mapFromGlobal(), and underMouse.
QPoint QWidget::mapFromGlobal ( const QPoint & pos ) const
Translates the global screen coordinate pos to widget coordinates.
See also mapToGlobal(), mapFrom(), and mapFromParent().
QPoint QWidget::mapFromParent ( const QPoint & pos ) const
Translates the parent widget coordinate pos to widget coordinates.
Same as mapFromGlobal() if the widget has no parent.
See also mapToParent(), mapFrom(), mapFromGlobal(), and underMouse.
QPoint QWidget::mapTo ( QWidget * parent, const QPoint & pos ) const
Translates the widget coordinate pos to the coordinate system of parent. The parent must not be 0 and must be a parent of the calling widget.
See also mapFrom(), mapToParent(), mapToGlobal(), and underMouse.
QPoint QWidget::mapToGlobal ( const QPoint & pos ) const
Translates the widget coordinate pos to global screen coordinates. For example, mapToGlobal(QPoint(0,0)) would give the global coordinates of the top-left pixel of the widget. 💫
See also mapFromGlobal(), mapTo(), and mapToParent().
Example: scribble/scribble.cpp.
QPoint QWidget::mapToParent ( const QPoint & pos ) const
Translates the widget coordinate pos to a coordinate in the parent widget.
Same as mapToGlobal() if the widget has no parent.
See also mapFromParent(), mapTo(), mapToGlobal(), and underMouse.
int QWidget::maximumHeight () const
Returns the widget's maximum height. See the "maximumHeight" property for details. 📏
QSize QWidget::maximumSize () const
Returns the widget's maximum size. See the "maximumSize" property for details.
int QWidget::maximumWidth () const
Returns the widget's maximum width. See the "maximumWidth" property for details.
int QWidget::metric ( int m ) const [virtual protected]
Internal implementation of the virtual QPaintDevice::metric() function.
Use the QPaintDeviceMetrics class instead.
m is the metric to get.
QRect QWidget::microFocusHint () const
Returns the currently set micro focus hint for this widget. See the "microFocusHint" property for details. 🔍
int QWidget::minimumHeight () const
Returns the widget's minimum height. See the "minimumHeight" property for details.
QSize QWidget::minimumSize () const
Returns the widget's minimum size. See the "minimumSize" property for details.
QSize QWidget::minimumSizeHint () const [virtual]
Returns the recommended minimum size for the widget. See the "minimumSizeHint" property for details. 🫶
Reimplemented in QLineEdit.
int QWidget::minimumWidth () const— hands you the widget's minimum width, no cap. Peep the"minimumWidth"property for the full tea.
void QWidget::mouseDoubleClickEvent ( QMouseEvent * e ) [virtual protected]— the event handler for evente, bestie, and you can reimplement it in a subclass to catch mouse double click events for your widget. ✨
The default implementation just generates a normal mouse press event, lowkey lazy but iconic.
Heads up though: the widget gets a mousePressEvent() and a mouseReleaseEvent() before the mouseDoubleClickEvent(). Order matters, iykyk.
See also mousePressEvent(), mouseReleaseEvent(), mouseMoveEvent(), event(), and QMouseEvent.
QWidget * QWidget::mouseGrabber () [static]— returns the widget that is currently grabbing the mouse input. 💅
If no widget in this application is grabbing the mouse rn, 0 gets returned, sad but true.
See also grabMouse() and keyboardGrabber().
void QWidget::mouseMoveEvent ( QMouseEvent * e ) [virtual protected]— the event handler for evente, and you can reimplement it in a subclass to receive mouse move events for the widget. 🦋
Here's the vibe check: if mouse tracking is switched off, mouse move events only occur if a mouse button is pressed while the mouse is being moved. But if mouse tracking is switched on, mouse move events occur even if no mouse button is pressed. ✨
QMouseEvent::pos() reports the position of the mouse cursor, relative to this widget. For press and release events, the position is usually the same as the position of the last mouse move event, but it might be different if the user's hand shakes. That's a feature of the underlying window system, not Qt — don't blame us bestie. 😭
See also mouseTracking, mousePressEvent(), mouseReleaseEvent(), mouseDoubleClickEvent(), event(), and QMouseEvent.
Examples:
Reimplemented in QSizeGrip.
void QWidget::mousePressEvent ( QMouseEvent * e ) [virtual protected]— event handler for evente, reimplement in a subclass to receive mouse press events for the widget. 👑
Real talk: if you create new widgets in the mousePressEvent() the mouseReleaseEvent() may not end up where you expect, depending on the underlying window system (or X11 window manager), the widgets' location and maybe more. Chaos, honestly.
The default implementation implements the closing of popup widgets when you click outside the window. For other widget types it does literally nothing.
See also mouseReleaseEvent(), mouseDoubleClickEvent(), mouseMoveEvent(), event(), and QMouseEvent.
Examples:
Reimplemented in QSizeGrip.
void QWidget::mouseReleaseEvent ( QMouseEvent * e ) [virtual protected]— event handler for evente, reimplement in a subclass to receive mouse release events for the widget. 🫶
See also mouseDoubleClickEvent(), mouseMoveEvent(), event(), and QMouseEvent.
Examples:
void QWidget::move ( const QPoint & ) [slot]— sets the position of the widget within its parent widget. Peep the"pos"property for details. 🌸void QWidget::move ( int x, int y ) [virtual slot]— this is an overloaded member function, provided for convenience. It behaves essentially like the above function.
This corresponds to move( QPoint(x, y) ). Slay, math checks out. ✨
void QWidget::moveEvent ( QMoveEvent * ) [virtual protected]— this event handler can be reimplemented in a subclass to receive widget move events. When the widget receives this event, it is already at the new position, no takebacks. 💅
The old position is accessible through QMoveEvent::oldPos().
See also resizeEvent(), event(), pos, and QMoveEvent.
bool QWidget::ownCursor () const— returnsTRUEif the widget uses its own cursor; otherwise returnsFALSE. See the"ownCursor"property for details.bool QWidget::ownFont () const— returnsTRUEif the widget uses its own font; otherwise returnsFALSE. See the"ownFont"property for details.bool QWidget::ownPalette () const— returnsTRUEif the widget uses its own palette; otherwise returnsFALSE. See the"ownPalette"property for details.void QWidget::paintEvent ( QPaintEvent * ) [virtual protected]— this event handler can be reimplemented in a subclass to receive paint events. 🎨
A paint event is a request to repaint all or part of the widget. It can happen as a result of repaint() or update(), or because the widget was obscured and has now been uncovered, or for many other reasons. Life comes at you fast.
Many widgets can simply repaint their entire surface when asked to, but some slow widgets need to optimize by painting only the requested region: QPaintEvent::region(). This speed optimization does not change the result, as painting is clipped to that region during event processing. QListView and QCanvas do this, for example. 👑
Qt also tries to speed up painting by merging multiple paint events into one. When update() is called several times or the window system sends several paint events, Qt merges these events into one event with a larger region (see QRegion::unite()). repaint() does not permit this optimization, so we suggest using update() when possible. fr fr, use update().
When the paint event occurs, the update region has normally been erased, so that you're painting on the widget's background. There are a couple of exceptions and QPaintEvent::erased() tells you whether the widget has been erased or not.
The background can be set using setBackgroundMode(), setPaletteBackgroundColor() or setBackgroundPixmap(). The documentation for setBackgroundMode() elaborates on the background; we recommend reading it. 🌈
See also event(), repaint(), update(), QPainter, QPixmap, and QPaintEvent.
Examples:
Reimplemented in QButton, QFrame, QGLWidget, QSizeGrip, QStatusBar, and QTabBar.
const QPalette & QWidget::palette () const— returns the widget's palette. See the"palette"property for details.const QColor & QWidget::paletteBackgroundColor () const— returns the background color of the widget. See the"paletteBackgroundColor"property for details.const QPixmap * QWidget::paletteBackgroundPixmap () const— returns the background pixmap of the widget. See the"paletteBackgroundPixmap"property for details.void QWidget::paletteChange ( const QPalette & oldPalette ) [virtual protected]— this virtual function is called fromsetPalette().oldPaletteis the previous palette; you can get the new palette frompalette(). 🎀
Reimplement this function if your widget needs to know when its palette changes.
See also palette and palette.
const QColor & QWidget::paletteForegroundColor () const— returns the foreground color of the widget. See the"paletteForegroundColor"property for details.QWidget * QWidget::parentWidget ( bool sameWindow = FALSE ) const— returns the parent of this widget, or0if it does not have any parent widget. IfsameWindowisTRUEand the widget is top level returns0; otherwise returns the widget's parent. 💜
Example: mdi/application.cpp.
void QWidget::polish () [virtual slot]— delayed initialization of a widget. 🧚
This function will be called after a widget has been fully created and before it is shown the very first time.
Polishing is useful for final initialization which depends on having an instantiated widget. This is something a constructor cannot guarantee since the initialization of the subclasses might not be finished. Classic constructor problem.
After this function, the widget has a proper font and palette and QApplication::polish() has been called.
Remember to call QWidget's implementation first when reimplementing this function to ensure that your program does not end up in infinite recursion. 😭 Do not skip this, bestie.
See also constPolish() and QApplication::polish().
Example: menu/menu.cpp.
QPoint QWidget::pos () const— returns the position of the widget within its parent widget. See the"pos"property for details.bool QWidget::qwsEvent ( QWSEvent * ) [virtual protected]— this special event handler can be reimplemented in a subclass to receive native Qt/Embedded events. 🌸
In your reimplementation of this function, if you want to stop the event being handled by Qt, return TRUE. If you return FALSE, this native event is passed back to Qt, which translates the event into a Qt event and sends it to the widget.
Warning: This function is not portable. ⚠️
See also QApplication::qwsEventFilter().
void QWidget::raise () [slot]— raises this widget to the top of the parent widget's stack. 👑
After this call the widget will be visually in front of any overlapping sibling widgets. Main character energy, honestly.
See also lower() and stackUnder().
Example: showimg/showimg.cpp.
void QWidget::recreate ( QWidget * parent, WFlags f, const QPoint & p, bool showIt = FALSE )— 🚨 this function is obsolete. It is provided to keep old source working. We strongly advise against using it in new code.
This method is provided to aid porting from Qt 1.0 to 2.0. It has been renamed reparent() in Qt 2.0. So like, glow up and use the new name. 💅
QRect QWidget::rect () const— returns the internal geometry of the widget excluding any window frame. See the"rect"property for details.void QWidget::releaseKeyboard ()— releases the keyboard grab.
See also grabKeyboard(), grabMouse(), and releaseMouse().
void QWidget::releaseMouse ()— releases the mouse grab.
See also grabMouse(), grabKeyboard(), and releaseKeyboard().
void QWidget::repaint ( int x, int y, int w, int h, bool erase = TRUE ) [slot]— repaints the widget directly by callingpaintEvent()immediately, unless updates are disabled or the widget is hidden. ⚡
If erase is TRUE, Qt erases the area (x, y, w, h) before the paintEvent() call.
If w is negative, it is replaced with width() - x, and if h is negative, it is replaced width height() - y.
We suggest only using repaint() if you need an immediate repaint, for example during animation. In almost all circumstances update() is better, as it permits Qt to optimize for speed and minimize flicker. ✨
Warning: If you callrepaint()in a function which may itself be called frompaintEvent(), you may get infinite recursion. Theupdate()function never causes recursion. 🫠
See also update(), paintEvent(), updatesEnabled, and erase().
Example: qwerty/qwerty.cpp.
void QWidget::repaint () [slot]— this is an overloaded member function, provided for convenience. It behaves essentially like the above function.
This version erases and repaints the entire widget.
void QWidget::repaint ( bool erase ) [slot]— this is an overloaded member function, provided for convenience. It behaves essentially like the above function.
This version repaints the entire widget.
void QWidget::repaint ( const QRect & r, bool erase = TRUE ) [slot]— this is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Repaints the widget directly by calling paintEvent() directly, unless updates are disabled or the widget is hidden.
Erases the widget region r if erase is TRUE.
void QWidget::repaint ( const QRegion & reg, bool erase = TRUE )[slot]— okay so this is an overloaded member function, there for convenience, and it behaves essentially like the one right above it 💫
It repaints the widget directly by calling paintEvent() directly — unless updates are disabled or the widget is hidden, in which case nah, nothing happens.
It erases the widget region reg if erase is TRUE.
Only use repaint if your widget literally needs to be repainted immediately, like when you're doing some animation. In all other cases, use update(). Calling update() many times in a row will generate a single paint event — it's giving efficiency, bestie ✨
Warning: if you callrepaint()in a function which may itself be called frompaintEvent(), you may get infinite recursion 😭💀 Theupdate()function never causes recursion. Choose wisely.
See also update(), paintEvent(), updatesEnabled, and erase().
void QWidget::reparent ( QWidget * parent, WFlags f, const QPoint & p, bool showIt = FALSE )[virtual]— reparents the widget, no cap 🫶 The widget gets a new parent, new widget flags (f, but as usual, use0), at a new position in its new parent (p).
If showIt is TRUE, show() is called once the widget has been reparented.
If the new parent widget is in a different top-level widget, the reparented widget and its children are appended to the end of the tab chain of the new parent widget, in the same internal order as before. And if one of the moved widgets had keyboard focus, reparent() calls clearFocus() for that widget.
If the new parent widget is in the same top-level widget as the old parent, reparent doesn't change the tab order or keyboard focus. Consistent king 👑
Warning: it is extremely unlikely that you will ever need this function 💀 If you have a widget that changes its content dynamically, it is far easier to useQWidgetStackorQWizard. Like, why make your life hard?
See also getWFlags().
Example: toplevel/options.ui.h.
void QWidget::reparent ( QWidget * parent, const QPoint & p, bool showIt = FALSE )— this is an overloaded member function, provided for convenience, and it behaves essentially like the above function ✨
A convenience version of reparent that does not take widget flags as argument.
Calls reparent(parent, getWFlags() & ~WType_Mask, p, showIt).
void QWidget::resetInputContext ()[protected]— this function is called when the user finishes input composition, e.g. changes focus to another widget, moves the cursor, etc. 🎀void QWidget::resize ( const QSize & )[slot]— sets the size of the widget excluding any window frame. See the "size" property for details 💅void QWidget::resize ( int w, int h )[virtual slot]— overloaded member function, provided for convenience, behaves essentially like the above function 🦋
This corresponds to resize( QSize(w, h) ).
void QWidget::resizeEvent ( QResizeEvent * )[virtual protected]— this event handler can be reimplemented in a subclass to receive widget resize events ✨ WhenresizeEvent()is called, the widget already has its new geometry. The old size is accessible throughQResizeEvent::oldSize().
The widget will be erased and receive a paint event immediately after processing the resize event. No drawing need be (or should be) done inside this handler — like, chill, it's handled 🧚
Widgets that have been created with the WNoAutoErase flag will not be erased. Nevertheless, they will receive a paint event for their entire area afterwards. Again, no drawing needs to be done inside this handler.
The default implementation calls updateMask() if the widget has automatic masking enabled.
See also moveEvent(), event(), size, QResizeEvent, and paintEvent().
Examples:
Reimplemented in QFrame and QGLWidget.
void QWidget::scroll ( int dx, int dy )— scrolls the widget including its childrendxpixels to the right anddydownwards. Bothdxanddymay be negative 👑
After scrolling, scroll() sends a paint event for the the part that is read but not written. For example, when scrolling 10 pixels rightwards, the leftmost ten pixels of the widget need repainting. The paint event may be delivered immediately or later, depending on some heuristics (note that you might have to force processing of paint events using QApplication::sendPostedEvents() when using scroll() and move() in combination) 🙈
See also QScrollView, erase(), and bitBlt().
void QWidget::scroll ( int dx, int dy, const QRect & r )— overloaded member function, provided for convenience, behaves essentially like the above function 💖
This version only scrolls r and does not move the children of the widget.
If r is empty or invalid, the result is undefined 💀
See also QScrollView, erase(), and bitBlt().
void QWidget::setAcceptDrops ( bool on )[virtual]— sets whether drop events are enabled for this widget toon. See the "acceptDrops" property for details 🌸void QWidget::setActiveWindow ()[virtual]— sets the top-level widget containing this widget to be the active window ✨
An active window is a visible top-level window that has the keyboard input focus.
This function performs the same operation as clicking the mouse on the title bar of a top-level window. On X11, the result depends on the Window Manager. If you want to ensure that the window is stacked on top as well you should also call raise(). Note that the window must be visible, otherwise setActiveWindow() has no effect.
On Windows, if you are calling this when the application is not currently the active one then it will not make it the active window. It will flash the task bar entry blue to indicate that the window has done something. This is because Microsoft do not allow an application to interrupt what the user is currently doing in another application 😭
See also isActiveWindow, topLevelWidget(), and show().
Reimplemented in QXtWidget.
void QWidget::setAutoMask ( bool )[virtual]— sets whether the auto mask feature is enabled for the widget. See the "autoMask" property for details 🎀void QWidget::setBackgroundColor ( const QColor & c )[virtual]— okay bestie, this function is obsolete. It is provided to keep old source working. We strongly advise against using it in new code. UsesetPaletteBackgroundColor()orsetEraseColor()instead 💅
Examples:
void QWidget::setBackgroundMode ( BackgroundMode )[virtual]— sets the color role used for painting the background of the widget. See the "backgroundMode" property for details 🦋void QWidget::setBackgroundMode ( BackgroundMode m, BackgroundMode visual )— overloaded member function, provided for convenience, behaves essentially like the above function ✨
Sets the widget's own background mode to m and the visual background mode to visual. The visual background mode is used with the designable properties backgroundColor, foregroundColor and backgroundPixmap.
For complex controls, the logical background mode sometimes differs from a widget's own background mode. A spinbox for example has PaletteBackground as background mode (typically dark gray), while it's embedded lineedit control uses PaletteBase (typically white). Since the lineedit covers most of the visual area of a spinbox, it defines PaletteBase to be its visual background mode. Changing the backgroundColor property thus changes the lineedit control's background, which is exactly what the user expects in Qt Designer 👑
void QWidget::setBackgroundOrigin ( BackgroundOrigin )[virtual]— sets the origin of the widget's background. See the "backgroundOrigin" property for details 🌸void QWidget::setBackgroundPixmap ( const QPixmap & pm )[virtual]— another obsolete one, bestie 😭 It is provided to keep old source working. We strongly advise against using it in new code. UsesetPaletteBackgroundPixmap()orsetErasePixmap()instead.
Example: desktop/desktop.cpp.
void QWidget::setBaseSize ( const QSize & )— sets the base size of the widget. See the "baseSize" property for details 💫void QWidget::setBaseSize ( int basew, int baseh )— overloaded member function, provided for convenience, behaves essentially like the above function 🎀
This corresponds to setBaseSize( QSize(basew, baseh) ). Sets the widgets base size to width basew and height baseh.
void QWidget::setCaption ( const QString & )[virtual slot]— sets the window caption (title). See the "caption" property for details 👑void QWidget::setCursor ( const QCursor & )[virtual]— sets the cursor shape for this widget. See the "cursor" property for details 💅void QWidget::setDisabled ( bool disable )[slot]— disables widget input events ifdisableisTRUE; otherwise enables input events.
See the enabled documentation for more information.
See also isEnabledTo(), QKeyEvent, QMouseEvent, and enabledChange().
void QWidget::setEnabled ( bool )[virtual slot]— sets whether the widget is enabled. See the "enabled" property for details ✨void QWidget::setEraseColor ( const QColor & color )[virtual]— sets the erase color of the widget tocolor🎀
The erase color is the color the widget is to be cleared to before paintEvent() is called. If there is an erase pixmap (set using setErasePixmap()), then this property has an indeterminate value. Spooky 💀
See also erasePixmap(), backgroundColor(), backgroundMode, and palette.
void QWidget::setErasePixmap ( const QPixmap & pixmap )[virtual]— sets the widget's erase pixmap topixmap🌈
This pixmap is used to clear the widget before paintEvent() is called.
void QWidget::setFixedHeight ( int h )— sets both the minimum and maximum heights of the widget tohwithout changing the widths. Provided for convenience 🫶
See also sizeHint, minimumSize, maximumSize, and setFixedSize().
Examples:
void QWidget::setFixedSize ( const QSize & s )— sets both the minimum and maximum sizes of the widget tos, thereby preventing it from ever growing or shrinking. Locked in, literally 🔒✨
See also maximumSize and minimumSize.
void QWidget::setFixedSize ( int w, int h )— overloaded member function, provided for convenience, behaves essentially like the above function 💖
Sets the width of the widget to w and the height to h.
void QWidget::setFixedWidth ( int w )— sets both the minimum and maximum width of the widget towwithout changing the heights. Provided for convenience 👑
See also sizeHint, minimumSize, maximumSize, and setFixedSize().
Examples:
void QWidget::setFocus () [virtual slot]
okay so this one is literally the "give me the keyboard, it's my turn" button 💅 It hands keyboard input focus to this widget — or to its focus proxy, bestie, we don't forget the proxy — but ONLY if this widget or one of its parents is the active window. no active window, no focus, sorry babe.
Here's the lil sequence of events, and yes it matters:
- First, a focus out event gets sent to the focus widget (if there is one) to tell it "hey you're about to lose the focus, no hard feelings."
- Then a focus in event gets sent to this widget like "you're up, main character."
(Nothing happens if the focus in and focus out widgets are the same. like, why bother.)
setFocus() gives focus to a widget regardless of its focus policy — so it doesn't care what your policy says, it just does it — but it does not clear any keyboard grab (peep grabKeyboard() for that).
Be aware that if the widget is hidden, it will not accept focus. hidden widget said "not today" 🙈
Warning: If you callsetFocus()in a function which may itself be called fromfocusOutEvent()orfocusInEvent(), you may get an infinite recursion. That's the "hello darkness my old friend" loop 💀 do not do it.
See also focus, clearFocus(), focusInEvent(), focusOutEvent(), focusPolicy, QApplication::focusWidget(), grabKeyboard(), and grabMouse().
Examples:
void QWidget::setFocusPolicy ( FocusPolicy ) [virtual]
Sets the way the widget accepts keyboard focus. See the "focusPolicy" property for details. that's it, that's the tweet 🎀
void QWidget::setFocusProxy ( QWidget * w ) [virtual]
Sets the widget's focus proxy to widget w. And if w is 0? The function resets this widget to have no focus proxy. poof, gone ✨
So some widgets, like QComboBox, can "have focus", but they create a child widget to actually handle the focus. QComboBox, for example, creates a QLineEdit which handles the focus. it's giving "I'm the face but my bestie does the work" 👑
setFocusProxy() sets the widget which will actually get focus when "this widget" gets it. If there is a focus proxy, focusPolicy(), setFocusPolicy(), setFocus() and hasFocus() all operate on the focus proxy. all of them. no exceptions.
See also focusProxy().
void QWidget::setFont ( const QFont & ) [virtual]
Sets the font currently set for the widget. See the "font" property for details.
Reimplemented in QComboBox, QLabel, and QTabDialog.
void QWidget::setFont ( const QFont & f, bool )
This function is obsolete. It is provided to keep old source working. We strongly advise against using it in new code. ngl bestie, retire it 🪦
Use setFont(const QFont& font) instead.
void QWidget::setGeometry ( const QRect & ) [virtual slot]
Sets the geometry of the widget relative to its parent and excluding the window frame. See the "geometry" property for details.
void QWidget::setGeometry ( int x, int y, int w, int h ) [virtual slot]
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
This corresponds to setGeometry( QRect(x, y, w, h) ). same energy, different signature 💫
void QWidget::setHidden ( bool hide ) [slot]
Sets whether the widget is explicitly hidden to hide. See the "hidden" property for details.
void QWidget::setIcon ( const QPixmap & ) [virtual slot]
Sets the widget's icon. See the "icon" property for details.
void QWidget::setIconText ( const QString & ) [virtual slot]
Sets the widget's icon text. See the "iconText" property for details.
void QWidget::setInputMethodEnabled ( bool b )
Sets enables or disables the use of input methods for this widget to b. See the "inputMethodEnabled" property for details.
void QWidget::setKeyCompression ( bool compress ) [virtual protected]
Enables key event compression, if compress is TRUE, and disables it if compress is FALSE. the toggling, we love to see it 🌸
Key compression is off by default (except for QLineEdit and QTextEdit), so widgets receive one key press event for each key press (or more, since autorepeat is usually on). If you turn it on and your program doesn't keep up with key input, Qt may try to compress key events so that more than one character can be processed in each event.
For example, a word processor widget might receive 2, 3 or more characters in each QKeyEvent::text(), if the layout recalculation takes too long for the CPU. it's giving "I'm behind, lemme batch this" 😭
If a widget supports multiple character unicode input, it is always safe to turn the compression on.
Qt performs key event compression only for printable characters. Modifier keys, cursor movement keys, function keys and miscellaneous action keys (e.g. Escape, Enter, Backspace, PrintScreen) will stop key event compression, even if there are more compressible key events available. those keys said "we're built different" 🔥
Not all platforms support this compression, in which case turning it on will have no effect. so if it's doing nothing, that might just be the platform, not you 🫶
See also QKeyEvent::text().
void QWidget::setMask ( const QBitmap & bitmap ) [virtual]
Causes only the pixels of the widget for which bitmap has a corresponding 1 bit to be visible. Use Qt::color0 to draw transparent regions and Qt::color1 to draw opaque regions of the bitmap. it's the stencil of doom (affectionate) 🎀
If the region includes pixels outside the rect() of the widget, window system controls in that area may or may not be visible, depending on the platform.
Note that this effect can be slow if the region is particularly complex. complex region = slow widget, sorry 💀
See examples/tux for an example of masking for transparency.
See also clearMask().
void QWidget::setMask ( const QRegion & region ) [virtual]
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Causes only the parts of the widget which overlap region to be visible. If the region includes pixels outside the rect() of the widget, window system controls in that area may or may not be visible, depending on the platform.
Note that this effect can be slow if the region is particularly complex.
See also clearMask().
void QWidget::setMaximumHeight ( int maxh )
Sets the widget's maximum height to maxh. See the "maximumHeight" property for details.
void QWidget::setMaximumSize ( const QSize & )
Sets the widget's maximum size. See the "maximumSize" property for details.
void QWidget::setMaximumSize ( int maxw, int maxh ) [virtual]
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
This function corresponds to setMaximumSize( QSize(maxw, maxh) ). Sets the maximum width to maxw and the maximum height to maxh. two numbers, one vibe ✨
void QWidget::setMaximumWidth ( int maxw )
Sets the widget's maximum width to maxw. See the "maximumWidth" property for details.
void QWidget::setMicroFocusHint ( int x, int y, int width, int height, bool text = TRUE, QFont * f = 0 ) [virtual protected]
When a widget gets focus, it should call setMicroFocusHint() with some appropriate position and size, x, y, width and height. This has no visual effect, it just provides hints to any system-specific input handling tools. so it's like a lil whisper to the OS, not a glow-up 🌸
The text argument should be TRUE if this is a position for text input.
In the Windows version of Qt, this method sets the system caret, which is used for user Accessibility focus handling. If text is TRUE, it also sets the IME composition window in Far East Asian language input systems.
In the X11 version of Qt, if text is TRUE, this method sets the XIM "spot" point for complex language input handling.
The font f is a rendering hint to the currently active input method. If f is 0 the widget's font is used.
See also microFocusHint.
void QWidget::setMinimumHeight ( int minh )
Sets the widget's minimum height to minh. See the "minimumHeight" property for details.
void QWidget::setMinimumSize ( const QSize & )
Sets the widget's minimum size. See the "minimumSize" property for details.
void QWidget::setMinimumSize ( int minw, int minh ) [virtual]
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
This function corresponds to setMinimumSize( QSize(minw, minh) ). Sets the minimum width to minw and the minimum height to minh.
void QWidget::setMinimumWidth ( int minw )
Sets the widget's minimum width to minw. See the "minimumWidth" property for details.
void QWidget::setMouseTracking ( bool enable ) [virtual slot]
Sets whether mouse tracking is enabled for the widget to enable. See the "mouseTracking" property for details.
void QWidget::setPalette ( const QPalette & ) [virtual]
Sets the widget's palette. See the "palette" property for details.
Reimplemented in QComboBox, QScrollBar, and QSlider.
void QWidget::setPalette ( const QPalette & p, bool )
This function is obsolete. It is provided to keep old source working. We strongly advise against using it in new code. let it rest, bestie 🪦✨
Use setPalette( const QPalette& p ) instead.
void QWidget::setPaletteBackgroundColor ( const QColor & ) [virtual]
Sets the background color of the widget. See the "paletteBackgroundColor" property for details.
void QWidget::setPaletteBackgroundPixmap ( const QPixmap & ) [virtual]
Sets the background pixmap of the widget. See the "paletteBackgroundPixmap" property for details.
void QWidget::setPaletteForegroundColor ( const QColor & )
Sets the foreground color of the widget. See the "paletteForegroundColor" property for details.
void QWidget::setShown ( bool show ) [slot]
Sets whether the widget is shown to show. See the "shown" property for details.
void QWidget::setSizeIncrement ( const QSize & )
Sets the size increment of the widget. See the "sizeIncrement" property for details.
void QWidget::setSizeIncrement ( int w, int h ) [virtual]
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Sets the x (width) size increment to w and the y (height) size increment to h. 🌈
void QWidget::setSizePolicy ( QSizePolicy ) [virtual]
Sets the default layout behavior of the widget. See the "sizePolicy" property for details.
void QWidget::setSizePolicy ( QSizePolicy::SizeType hor, QSizePolicy::SizeType ver, bool hfw = FALSE )
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Sets the size policy of the widget to hor, ver and hfw (height for width).
See also QSizePolicy::QSizePolicy().
void QWidget::setStyle ( QStyle * style )
Sets the widget's GUI style to style. Ownership of the style object is not transferred. so don't go deleting it later thinking it's yours, it's not 💅
If no style is set, the widget uses the application's style, QApplication::style() instead.
Setting a widget's style has no effect on existing or future child widgets. the children said "we have our own aesthetic" 🦋
Warning: This function is particularly useful for demonstration purposes, where you want to show Qt's styling capabilities. Real applications should avoid it and use one consistent GUI style instead. fr fr, demo code only, bestie.
See also style(), QStyle, QApplication::style(), and QApplication::setStyle().
Examples:
QStyle * QWidget::setStyle ( const QString & style )
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Sets the widget's GUI style to style using the QStyleFactory. factory setting, iconic 👑
void QWidget::setTabOrder ( QWidget * first, QWidget * second ) [static]
Okay bestie, this one is so useful. It moves the second widget around the ring of focus widgets so that when you hit Tab, keyboard focus hops from first over to second. 💅
Lowkey important detail: because it changes the tab order of the second widget, you gotta chain them in order like this:
setTabOrder( a, b ); // a to b
setTabOrder( b, c ); // a to b to c
setTabOrder( c, d ); // a to b to c to d
and NOT like this:
setTabOrder( c, d ); // c to d WRONG
setTabOrder( a, b ); // a to b AND c to d
setTabOrder( b, c ); // a to b to c, but not c to d
If first or second has a focus proxy, setTabOrder() correctly substitutes the proxy. iconic behaviour fr fr. ✨
See also focusPolicy and setFocusProxy().
Example: customlayout/main.cpp.
void QWidget::setUpdatesEnabled ( bool enable ) [virtual slot]
Sets whether updates are enabled to enable. See the "updatesEnabled" property for the deets. 🫶
void QWidget::setWFlags ( WFlags f ) [virtual protected]
Sets the widget flags f.
Widget flags are a combination of Qt::WidgetFlags.
See also testWFlags(), getWFlags(), and clearWFlags().
void QWidget::setWindowOpacity ( double level )
Sets the level of opacity for the window to level. See the "windowOpacity" property for details. translucent era 💖
void QWidget::setWindowState ( uint windowState )
Sets the window state to windowState. The window state is a OR'ed combination of Qt::WindowState: WindowMinimized, WindowMaximized, WindowFullScreen and WindowActive. 🪟
If the window is not visible (i.e. isVisible() returns FALSE), the window state will take effect when show() is called. For visible windows, the change is immediate. For example, to toggle between full-screen and mormal mode, use the following code:
w->setWindowState(w->windowState() ^ WindowFullScreen);
In order to restore and activate a minimized window (while preserving its maximized and/or full-screen state), use the following:
w->setWindowState(w->windowState() & ~WindowMinimized | WindowActive);
Note: On some window systems WindowActive is not immediate, and may be ignored in certain cases. 🙈
See also Qt::WindowState and windowState().
void QWidget::show () [virtual slot]
Shows the widget and its child widgets. the moment we've all been waiting for ✨
If its size or position has changed, Qt guarantees that a widget gets move and resize events just before it is shown.
You almost never have to reimplement this function. If you need to change some settings before a widget is shown, use showEvent() instead. If you need to do some delayed initialization use polish().
See also showEvent(), hide(), showMinimized(), showMaximized(), showNormal(), visible, and polish().
Examples:
Reimplemented in QDialog and QMenuBar.
void QWidget::showEvent ( QShowEvent * ) [virtual protected]
This event handler can be reimplemented in a subclass to receive widget show events.
Non-spontaneous show events are sent to widgets immediately before they are shown. The spontaneous show events of top-level widgets are delivered afterwards.
See also event() and QShowEvent.
Example: qdir/qdir.cpp.
void QWidget::showFullScreen () [slot]
Shows the widget in full-screen mode. main character energy, literally taking up the whole screen 👑
Calling this function only affects top-level widgets.
To return from full-screen mode, call showNormal().
Full-screen mode works fine under Windows, but has certain problems under X. These problems are due to limitations of the ICCCM protocol that specifies the communication between X11 clients and the window manager. ICCCM simply does not understand the concept of non-decorated full-screen windows. Therefore, the best we can do is to request a borderless window and place and resize it to fill the entire screen. Depending on the window manager, this may or may not work. The borderless window is requested using MOTIF hints, which are at least partially supported by virtually all modern window managers.
An alternative would be to bypass the window manager entirely and create a window with the WX11BypassWM flag. This has other severe problems though, like totally broken keyboard focus and very strange effects on desktop changes or when the user raises other windows. 💀 so yeah, be careful.
X11 window managers that follow modern post-ICCCM specifications support full-screen mode properly.
See also showNormal(), showMaximized(), show(), hide(), and visible.
void QWidget::showMaximized () [virtual slot]
Shows the widget maximized. big mode activated 🌈
Calling this function only affects top-level widgets.
On X11, this function may not work properly with certain window managers. See the Window Geometry documentation for an explanation.
See also setWindowState(), showNormal(), showMinimized(), show(), hide(), and visible.
Examples:
void QWidget::showMinimized () [virtual slot]
Shows the widget minimized, as an icon. tiny mode 🎀
Calling this function only affects top-level widgets.
See also showNormal(), showMaximized(), show(), hide(), visible, and minimized.
void QWidget::showNormal () [virtual slot]
Restores the widget after it has been maximized or minimized. back to baseline bestie 💖
Calling this function only affects top-level widgets.
See also setWindowState(), showMinimized(), showMaximized(), show(), hide(), and visible.
Example: mdi/application.cpp.
QSize QWidget::size () const
Returns the size of the widget excluding any window frame. See the "size" property for details.
QSize QWidget::sizeHint () const [virtual]
Returns the recommended size for the widget. See the "sizeHint" property for details.
Reimplemented in QSizeGrip.
QSize QWidget::sizeIncrement () const
Returns the size increment of the widget. See the "sizeIncrement" property for details.
QSizePolicy QWidget::sizePolicy () const [virtual]
Returns the default layout behavior of the widget. See the "sizePolicy" property for details.
void QWidget::stackUnder ( QWidget * w ) [slot]
Places the widget under w in the parent widget's stack. 📚
To make this work, the widget itself and w must be siblings. no sibling energy, no stacking, that's just how it is.
See also raise() and lower().
QStyle & QWidget::style () const
Returns the GUI style for this widget. 💅
See also QWidget::setStyle(), QApplication::setStyle(), and QApplication::style().
void QWidget::styleChange ( QStyle & oldStyle ) [virtual protected]
This virtual function is called when the style of the widgets changes. oldStyle is the previous GUI style; you can get the new style from style().
Reimplement this function if your widget needs to know when its GUI style changes. You will almost certainly need to update the widget using update().
The default implementation updates the widget including its geometry.
See also QApplication::setStyle(), style(), update(), and updateGeometry().
void QWidget::tabletEvent ( QTabletEvent * e ) [virtual protected]
This event handler, for event e, can be reimplemented in a subclass to receive tablet events for the widget. 🖊️ yes, like a drawing tablet, not the pill.
If you reimplement this handler, it is very important that you ignore() the event if you do not handle it, so that the widget's parent can interpret it.
The default implementation ignores the event.
See also QTabletEvent::ignore(), QTabletEvent::accept(), event(), and QTabletEvent.
WFlags QWidget::testWFlags ( WFlags f ) const
Returns the bitwise AND of the widget flags and f.
Widget flags are a combination of Qt::WidgetFlags.
If you want to test for the presence of multiple flags (or composite flags such as WStyle_Splash), test the return value for equality against the argument. For example:
int flags = WStyle_Tool | WStyle_NoBorder;
if ( testWFlags(flags) )
... // WStyle_Tool or WStyle_NoBorder or both are set
if ( testWFlags(flags) == flags )
... // both WStyle_Tool and WStyle_NoBorder are set
See also getWFlags(), setWFlags(), and clearWFlags().
QWidget * QWidget::topLevelWidget () const
Returns the top-level widget for this widget, i.e. the next ancestor widget that has (or could have) a window-system frame.
If the widget is a top-level, the widget itself is returned.
Typical usage is changing the window caption:
aWidget->topLevelWidget()->setCaption( "New Caption" );
See also isTopLevel.
void QWidget::unsetCursor () [virtual]
Resets the cursor shape for this widget. See the "cursor" property for details.
void QWidget::unsetFont ()
Resets the font currently set for the widget. See the "font" property for details.
void QWidget::unsetPalette ()
Resets the widget's palette. See the "palette" property for details.
void QWidget::update () [slot]
Updates the widget unless updates are disabled or the widget is hidden. ✨
This function does not cause an immediate repaint; instead it schedules a paint event for processing when Qt returns to the main event loop. This permits Qt to optimize for more speed and less flicker than a call to repaint() does. it's giving efficient 💅
Calling update() several times normally results in just one paintEvent() call. queen of not doing extra work.
Qt normally erases the widget's area before the paintEvent() call. If the WRepaintNoErase widget flag is set, the widget is responsible for painting all its pixels itself.
See also repaint(), paintEvent(), updatesEnabled, erase(), and setWFlags().
Examples:
void QWidget::update ( int x, int y, int w, int h ) [slot]
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Updates a rectangle (x, y, w, h) inside the widget unless updates are disabled or the widget is hidden.
This function does not cause an immediate repaint; instead it schedules a paint event for processing when Qt returns to the main event loop. This permits Qt to optimize for more speed and less flicker and a call to repaint() does.
Calling update() several times normally results in just one paintEvent() call.
If w is negative, it is replaced with width() - x. If h is negative, it is replaced width height() - y.
Qt normally erases the specified area before the paintEvent() call. If the WRepaintNoErase widget flag is set, the widget is responsible for painting all its pixels itself.
See also repaint(), paintEvent(), updatesEnabled, and erase().
void QWidget::update ( const QRect & r ) [slot]
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Updates a rectangle r inside the widget unless updates are disabled or the widget is hidden.
This function does not cause an immediate repaint; instead it schedules a paint event for processing when Qt returns to the main event loop. This permits Qt to optimize for more speed and less flicker and a call to repaint() does.
Calling update() several times normally results in just one paintEvent() call.
void QWidget::updateGeometry () Notifies the layout system that this widget has changed and may need to change geometry.
Call this function if the sizeHint() or sizePolicy() have changed.
For explicitly hidden widgets, updateGeometry() is a no-op. The layout system will be notified as soon as the widget is shown.
void QWidget::updateGeometry ()— bestie, this is the "hey layout system, I changed, maybe recalc my geometry" ping 💅. Call it wheneversizeHint()orsizePolicy()have shifted. Lowkey important: for widgets that are explicitly hidden,updateGeometry()is a no-op — the layout system only gets the memo the second the widget is shown. No cap. 🦋
void QWidget::updateMask () [virtual protected]— okay so this one is reimplementable in a subclass to support transparent widgets ✨. It should be called any time a widget changes state in a way that means the shape mask has to be recalculated.
See also autoMask, setMask(), and clearMask().
QRect QWidget::visibleRect () const— hands you the visible rectangle. The"visibleRect"property has the details, go peek at it 👑.
void QWidget::wheelEvent ( QWheelEvent * e ) [virtual protected]— the event handler for event e, reimplementable in a subclass so you can receive wheel events for your widget. 🎡
If you do reimplement this handler, it is very important that you ignore() the event when you don't handle it, so the widget's parent can interpret it. Fr fr, don't skip that part. 😭
The default implementation ignores the event.
See also QWheelEvent::ignore(), QWheelEvent::accept(), event(), and QWheelEvent.
int QWidget::width () const— the width of the widget, excluding any window frame. The"width"property has the deets 💖.
bool QWidget::winEvent ( MSG * ) [virtual protected]— a special event handler, reimplementable in a subclass to receive native Windows events 🪟.
In your reimplementation: if you want to stop the event from being handled by Qt, return TRUE. If you return FALSE, the native event gets passed back to Qt, which translates it into a Qt event and sends it to the widget.
Warning: This function is not portable. 🚨
See also QApplication::winEventFilter().
WId QWidget::winId () const— returns the window system identifier of the widget.
Portable in principle, but bestie… if you're using it you're probably about to do something non-portable. Be careful 🙈.
See also find().
void QWidget::windowActivationChange ( bool oldActive ) [virtual protected]— this virtual function fires for a widget when its window gets activated or deactivated by the window system.oldActiveis the previous state; you can grab the new setting fromisActiveWindow(). ✨
Reimplement it if your widget needs to know when its window becomes activated or deactivated.
The default implementation updates the visible part of the widget if the inactive and the active colorgroup differ for colors other than the highlight and link colors.
See also setActiveWindow(), isActiveWindow, update(), and palette.
double QWidget::windowOpacity () const— returns the level of opacity for the window. The"windowOpacity"property has the details 🌈.
uint QWidget::windowState () const— returns the current window state. That state is an OR'ed combination ofQt::WindowState:WindowMinimized,WindowMaximized,WindowFullScreenandWindowActive. 👑
See also Qt::WindowState and setWindowState().
int QWidget::x () const— the x coordinate of the widget relative to its parent, including any window frame. The"x"property has the deets 💅.
bool QWidget::x11Event ( XEvent * ) [virtual protected]— another special event handler, reimplementable in a subclass to receive native X11 events 🖥️.
In your reimplementation: return TRUE if you want to stop the event from being handled by Qt. Return FALSE and the native event goes back to Qt, which translates it into a Qt event and sends it to the widget.
Warning: This function is not portable. 🚨
See also QApplication::x11EventFilter().
Reimplemented in QXtWidget.
int QWidget::y () const— the y coordinate of the widget relative to its parent and including any window frame. The"y"property has the details 🌸.
💖 Property Documentation 💖
bool acceptDrops— this property holds whether drop events are enabled for this widget. 🫳
Setting it to TRUE announces to the system that this widget may be able to accept drop events.
If the widget is the desktop (QWidget::isDesktop()), this may fail if another application is using the desktop; you can call acceptDrops() to test whether that happened.
Warning: Do not modify this property inside a Drag&Drop event handler. 😤
Set this property's value with setAcceptDrops() and get this property's value with acceptDrops().
bool autoMask— this property holds whether the auto mask feature is enabled for the widget. 🎭
Transparent widgets use a mask to define their visible region. QWidget has some built-in support to make recalculating that mask easier. When you set auto mask to TRUE, updateMask() gets called whenever the widget is resized or changes its focus state. Heads up though: you must reimplement updateMask() (and that reimplementation should include a call to setMask()) or literally nothing will happen 💀.
Note: when you re-implement resizeEvent(), focusInEvent() or focusOutEvent() in your custom widgets and still want the auto mask calculation to work, you should add:
if ( autoMask() )
updateMask();
at the end of your event handlers. This is true for all member functions that change the appearance of the widget in a way that requires a recalculation of the mask.
Okay so while masks are a technically appealing concept, they have a big drawback: when you use complex masks that can't easily be expressed with relatively simple regions, they can be very slow on some window systems 😭. The classic example is a transparent label — the complex shape of its contents makes it necessary to represent its mask by a bitmap, which eats both memory and time. If all you actually want is to blend the background of several neighboring widgets together seamlessly, you probably want setBackgroundOrigin() rather than a mask. Periodt.
See also updateMask(), setMask(), clearMask(), and backgroundOrigin.
Set this property's value with setAutoMask() and get this property's value with autoMask().
QBrush backgroundBrush— this property holds the widget's background brush. 🖌️
The background brush depends on a widget's palette and its background mode.
See also backgroundColor(), backgroundPixmap(), eraseColor(), palette, and QApplication::setPalette().
Get this property's value with backgroundBrush().
BackgroundMode backgroundMode— this property holds the color role used for painting the background of the widget. 🎨
setPaletteBackgroundColor() reads this property to figure out which entry of the palette to set.
For most widgets the default suffices (PaletteBackground, typically gray), but some need PaletteBase (the background color for text output, typically white) or another role.
QListBox, which is "sunken" and uses the base color to contrast with its environment, does this in its constructor:
setBackgroundMode( PaletteBase );
You will never need to set the background mode of a built-in widget in Qt, but you might consider setting it in your custom widgets so that setPaletteBackgroundColor() works as expected.
Note that two of the BackgroundMode values make no sense for setBackgroundMode(), namely FixedPixmap and FixedColor. You must call setBackgroundPixmap() and setPaletteBackgroundColor() instead. 😌
Set this property's value with setBackgroundMode() and get this property's value with backgroundMode().
BackgroundOrigin backgroundOrigin— this property holds the origin of the widget's background. 🦋
The origin is either WidgetOrigin (the default), ParentOrigin, WindowOrigin or AncestorOrigin.
This only makes a difference if the widget has a background pixmap, in which case positioning matters. Using WindowOrigin for several neighboring widgets makes the background blend together seamlessly. AncestorOrigin allows blending backgrounds seamlessly when an ancestor of the widget has an origin other than WindowOrigin. ✨
See also backgroundPixmap() and backgroundMode.
Set this property's value with setBackgroundOrigin() and get this property's value with backgroundOrigin().
QSize baseSize— this property holds the base size of the widget. 📐
The base size is used to calculate a proper widget size if the widget defines sizeIncrement().
See also sizeIncrement.
Set this property's value with setBaseSize() and get this property's value with baseSize().
QString caption— this property holds the window caption (title). 👑
This property only makes sense for top-level widgets. If no caption has been set, the caption is QString::null.
See also icon and iconText.
Set this property's value with setCaption() and get this property's value with caption().
QRect childrenRect— this property holds the bounding rectangle of the widget's children. 🎀
Hidden children are excluded.
See also childrenRegion and geometry.
Get this property's value with childrenRect().
QRegion childrenRegion— this property holds the combined region occupied by the widget's children. 🌸
Hidden children are excluded.
See also childrenRect and geometry.
Get this property's value with childrenRegion().
QColorGroup colorGroup— this property holds the current color group of the widget palette. 🌈
The color group is determined by the state of the widget. A disabled widget has the QPalette::disabled() color group, a widget with keyboard focus has the QPalette::active() color group, and an inactive widget has the QPalette::inactive() color group.
See also palette.
Get this property's value with colorGroup().
QCursor cursor— this property holds the cursor shape for this widget. 💅
The mouse cursor will assume this shape when it's over this widget. See the list of predefined cursor objects for a range of useful shapes.
An editor widget might use an I-beam cursor:
setCursor( IbeamCursor );
If no cursor has been set, or after a call to unsetCursor(), the parent's cursor is used. The function unsetCursor() has no effect on top-level widgets.
See also QApplication::setOverrideCursor().
Set this property's value with setCursor(), get this property's value with cursor(), and reset this property's value with unsetCursor().
bool customWhatsThis— this property holds whether the widget wants to handle What's This help manually. ❓
The default implementation of customWhatsThis() returns FALSE, which means the widget will not receive any events in Whats This mode.
The widget may leave What's This mode by calling QWhatsThis::leaveWhatsThisMode(), with or without actually displaying any help text.
You can also reimplement customWhatsThis() if your widget is a "passive interactor" supposed to work under all circumstances. Simply don't call QWhatsThis::leaveWhatsThisMode() in that case. 😌
See also QWhatsThis::inWhatsThisMode() and QWhatsThis::leaveWhatsThisMode().
Get this property's value with customWhatsThis().
bool enabled 💖
This property holds whether the widget is enabled, bestie.
An enabled widget receives keyboard and mouse events; a disabled widget does not. In fact, an enabled widget only receives keyboard events when it is in focus. No cap.
Some widgets display themselves differently when they are disabled. For example a button might draw its label grayed out. If your widget needs to know when it becomes enabled or disabled, you can reimplement the enabledChange() function.
Disabling a widget implicitly disables all its children. Enabling respectively enables all child widgets unless they have been explicitly disabled. It's giving cascading vibes.
See also enabled, isEnabledTo(), QKeyEvent, QMouseEvent, and enabledChange().
Set this property's value with setEnabled() and get this property's value with isEnabled().
bool focus 🔥
This property holds whether this widget (or its focus proxy) has the keyboard input focus.
Effectively equivalent to qApp->focusWidget() == this.
See also setFocus(), clearFocus(), focusPolicy, and QApplication::focusWidget().
Get this property's value with hasFocus().
bool focusEnabled ✨
This property holds whether the widget accepts keyboard focus.
Keyboard focus is initially disabled (i.e. focusPolicy() == QWidget::NoFocus).
You must enable keyboard focus for a widget if it processes keyboard events. This is normally done from the widget's constructor. For instance, the QLineEdit constructor calls setFocusPolicy(QWidget::StrongFocus).
See also focusPolicy, focusInEvent(), focusOutEvent(), keyPressEvent(), keyReleaseEvent(), and enabled.
Get this property's value with isFocusEnabled().
FocusPolicy focusPolicy 🎀
This property holds the way the widget accepts keyboard focus.
The policy is QWidget::TabFocus if the widget accepts keyboard focus by tabbing, QWidget::ClickFocus if the widget accepts focus by clicking, QWidget::StrongFocus if it accepts both, and QWidget::NoFocus (the default) if it does not accept focus at all.
You must enable keyboard focus for a widget if it processes keyboard events. This is normally done from the widget's constructor. For instance, the QLineEdit constructor calls setFocusPolicy(QWidget::StrongFocus).
See also focusEnabled, focusInEvent(), focusOutEvent(), keyPressEvent(), keyReleaseEvent(), and enabled.
Set this property's value with setFocusPolicy() and get this property's value with focusPolicy().
QFont font 🌸
This property holds the font currently set for the widget.
The fontInfo() function reports the actual font that is being used by the widget.
As long as no special font has been set, or after unsetFont() is called, this is either a special font for the widget class, the parent's font or (if this widget is a top level widget), the default application font.
This code fragment sets a 12 point helvetica bold font:
QFont f( "Helvetica", 12, QFont::Bold );
setFont( f );
In addition to setting the font, setFont() informs all children about the change.
See also fontChange(), fontInfo(), fontMetrics(), and ownFont.
Set this property's value with setFont(), get this property's value with font(), and reset this property's value with unsetFont().
QRect frameGeometry 🦋
This property holds geometry of the widget relative to its parent including any window frame.
See the Window Geometry documentation for an overview of geometry issues with top-level widgets.
See also geometry, x, y, and pos.
Get this property's value with frameGeometry().
QSize frameSize 🌈
This property holds the size of the widget including any window frame.
Get this property's value with frameSize().
bool fullScreen 👑
This property holds whether the widget is full screen.
Get this property's value with isFullScreen().
See also windowState(), minimized, and maximized.
QRect geometry 💅
This property holds the geometry of the widget relative to its parent and excluding the window frame.
When changing the geometry, the widget, if visible, receives a move event (moveEvent()) and/or a resize event (resizeEvent()) immediately. If the widget is not currently visible, it is guaranteed to receive appropriate events before it is shown.
The size component is adjusted if it lies outside the range defined by minimumSize() and maximumSize().
setGeometry() is virtual, and all other overloaded setGeometry() implementations in Qt call it.
Warning: CallingsetGeometry()insideresizeEvent()ormoveEvent()can lead to infinite recursion.
See the Window Geometry documentation for an overview of top-level widget geometry.
See also frameGeometry, rect, pos, size, moveEvent(), resizeEvent(), minimumSize, and maximumSize.
Set this property's value with setGeometry() and get this property's value with geometry().
int height 🍓
This property holds the height of the widget excluding any window frame.
See the Window Geometry documentation for an overview of top-level widget geometry.
See also geometry, width, and size.
Get this property's value with height().
bool hidden 🙈
This property holds whether the widget is explicitly hidden.
If FALSE, the widget is visible or would become visible if all its ancestors became visible.
See also hide(), show(), visible, isVisibleTo(), and shown.
Set this property's value with setHidden() and get this property's value with isHidden().
QPixmap icon 🖼️
This property holds the widget's icon.
This property only makes sense for top-level widgets. If no icon has been set, icon() returns 0.
See also iconText, caption, and Setting the Application Icon.
Set this property's value with setIcon() and get this property's value with icon().
QString iconText 💬
This property holds the widget's icon text.
This property only makes sense for top-level widgets. If no icon text has been set, this functions returns QString::null.
See also icon and caption.
Set this property's value with setIconText() and get this property's value with iconText().
bool inputMethodEnabled 🧚
This property holds enables or disables the use of input methods for this widget.
Most Widgets (as eg. buttons) that do not handle text input should have the input method disabled if they have focus. This is the default.
If a widget handles text input it should set this property to TRUE.
Set this property's value with setInputMethodEnabled() and get this property's value with isInputMethodEnabled().
bool isActiveWindow 🔥
This property holds whether this widget is the active window.
The active window is the window that contains the widget that has keyboard focus.
When popup windows are visible, this property is TRUE for both the active window and for the popup.
See also setActiveWindow() and QApplication::activeWindow().
Get this property's value with isActiveWindow().
bool isDesktop 🖥️
This property holds whether the widget is a desktop widget, i.e. represents the desktop.
A desktop widget is also a top-level widget.
See also isTopLevel and QApplication::desktop().
Get this property's value with isDesktop().
bool isDialog 💬
This property holds whether the widget is a dialog widget.
A dialog widget is a secondary top-level widget, i.e. a top-level widget with a parent.
See also isTopLevel and QDialog.
Get this property's value with isDialog().
bool isModal 🚫
This property holds whether the widget is a modal widget.
This property only makes sense for top-level widgets. A modal widget prevents widgets in all other top-level widgets from getting any input.
See also isTopLevel, isDialog, and QDialog.
Get this property's value with isModal().
bool isPopup 🎈
This property holds whether the widget is a popup widget.
A popup widget is created by specifying the widget flag WType_Popup to the widget constructor. A popup widget is also a top-level widget.
See also isTopLevel.
Get this property's value with isPopup().
bool isTopLevel 👑
This property holds whether the widget is a top-level widget.
A top-level widget is a widget which usually has a frame and a caption (title). Popup and desktop widgets are also top-level widgets.
A top-level widget can have a parent widget. It will then be grouped with its parent and deleted when the parent is deleted, minimized when the parent is minimized etc. If supported by the window manager, it will also have a common taskbar entry with its parent.
QDialog and QMainWindow widgets are by default top-level, even if a parent widget is specified in the constructor. This behavior is specified by the WType_TopLevel widget flag.
See also topLevelWidget(), isDialog, isModal, isPopup, isDesktop, and parentWidget().
Get this property's value with isTopLevel().
bool maximized 🗖
This property holds whether this widget is maximized.
This property is only relevant for top-level widgets.
Note that due to limitations in some window-systems, this does not always report the expected results (e.g. if the user on X11 maximizes the window via the window manager, Qt has no way of distinguishing this from any other resize). This is expected to improve as window manager protocols evolve.
See also windowState(), showMaximized(), visible, show(), hide(), showNormal(), and minimized.
Get this property's value with isMaximized().
int maximumHeight 📏
This property holds the widget's maximum height.
This property corresponds to maximumSize().height().
See also maximumSize and maximumWidth.
Set this property's value with setMaximumHeight() and get this property's value with maximumHeight().
QSize maximumSize 📐
This property holds the widget's maximum size.
The widget cannot be resized to a larger size than the maximum widget size.
See also maximumWidth, maximumHeight, maximumSize, minimumSize, and sizeIncrement.
Set this property's value with setMaximumSize() and get this property's value with maximumSize().
int maximumWidth 📏
This property holds the widget's maximum width.
This property corresponds to maximumSize().width().
See also maximumSize and maximumHeight.
Set this property's value with setMaximumWidth() and get this property's value with maximumWidth().
QRect microFocusHint 🔍
This property holds the currently set micro focus hint for this widget.
See the documentation of setMicroFocusHint() for more information.
Get this property's value with microFocusHint().
bool minimized 🗕
This property holds whether this widget is minimized (iconified).
This property is only relevant for top-level widgets.
See also showMinimized(), visible, show(), hide(), showNormal(), and maximized.
Get this property's value with isMinimized().
QSize minimumSize This property holds the widget's minimum size.
The widget cannot be resized to a smaller size than the minimum widget size. The widget's size is forced to the minimum size if the current size is smaller.
If you use a layout inside the widget, the minimum size will be set by the layout and not by setMinimumSize(), unless you set the layout's resize mode to QLayout::FreeResize.
See also minimumWidth, minimumHeight, maximumSize, sizeIncrement, and QLayout::resizeMode.
Set this property's value with setMinimumSize() and get this property's value with minimumSize().
QSize minimumSizeHint This property holds the recommended minimum size for the widget.
If the value of this property is an invalid size, no minimum size is recommended.
The default implementation of minimumSizeHint() returns an invalid size if there is no layout for this widget, and returns the layout's minimum size otherwise. Most built-in widgets reimplement minimumSizeHint().
QLayout will never resize a widget to a size smaller than minimumSizeHint.
See also QSize::isValid(), size, minimumSize, and sizePolicy.
Get this property's value with minimumSizeHint().
int minimumWidth This property holds the widget's minimum width.
This property corresponds to minimumSize().width().
See also minimumSize and minimumHeight.
Set this property's value with setMinimumWidth() and get this property's value with minimumWidth().
bool mouseTracking This property holds whether mouse tracking is enabled for the widget.
If mouse tracking is disabled (the default), the widget only receives mouse move events when at least one mouse button is pressed while the mouse is being moved.
If mouse tracking is enabled, the widget receives mouse move events even if no buttons are pressed.
See also mouseMoveEvent() and QApplication::setGlobalMouseTracking().
Set this property's value with setMouseTracking() and get this property's value with hasMouseTracking().
bool ownCursor This property holds whether the widget uses its own cursor.
If FALSE, the widget uses its parent widget's cursor.
See also cursor.
Get this property's value with ownCursor().
bool ownFont This property holds whether the widget uses its own font.
If FALSE, the widget uses its parent widget's font.
See also font.
Get this property's value with ownFont().
bool ownPalette This property holds whether the widget uses its own palette.
If FALSE, the widget uses its parent widget's palette.
See also palette.
Get this property's value with ownPalette().
QPalette palette This property holds the widget's palette.
As long as no special palette has been set, or after unsetPalette() has been called, this is either a special palette for the widget class, the parent's palette or (if this widget is a top level widget), the default application palette.
Instead of defining an entirely new palette, you can also use the paletteBackgroundColor, paletteBackgroundPixmap and paletteForegroundColor convenience properties to change a widget's background and foreground appearance only.
See also ownPalette, colorGroup, and QApplication::palette().
Set this property's value with setPalette(), get this property's value with palette(), and reset this property's value with unsetPalette().
QColor paletteBackgroundColor This property holds the background color of the widget.
The palette background color is usually set implicitly by setBackgroundMode(), although it can also be set explicitly by setPaletteBackgroundColor(). setPaletteBackgroundColor() is a convenience function that creates and sets a modified QPalette with setPalette(). The palette is modified according to the widget's background mode. For example, if the background mode is PaletteButton the color used for the palette's QColorGroup::Button color entry is set.
If there is a background pixmap (set using setPaletteBackgroundPixmap()), then the return value of this function is indeterminate.
See also paletteBackgroundPixmap, paletteForegroundColor, palette, and colorGroup.
Set this property's value with setPaletteBackgroundColor(), get this property's value with paletteBackgroundColor(), and reset this property's value with unsetPalette().
QPixmap paletteBackgroundPixmap This property holds the background pixmap of the widget.
The palette background pixmap is usually set implicitly by setBackgroundMode(), although it can also be set explicitly by setPaletteBackgroundPixmap(). setPaletteBackgroundPixmap() is a convenience function that creates and sets a modified QPalette with setPalette(). The palette is modified according to the widget's background mode. For example, if the background mode is PaletteButton the pixmap used for the palette's QColorGroup::Button color entry is set.
If there is a plain background color (set using setPaletteBackgroundColor()), then this function returns 0.
See also paletteBackgroundColor, paletteForegroundColor, palette, and colorGroup.
Set this property's value with setPaletteBackgroundPixmap(), get this property's value with paletteBackgroundPixmap(), and reset this property's value with unsetPalette().
QColor paletteForegroundColor This property holds the foreground color of the widget.
setPaletteForegroundColor() is a convenience function that creates and sets a modified QPalette with setPalette(). The palette is modified according to the widget's background mode. For example, if the background mode is PaletteButton the palette entry QColorGroup::ButtonText is set to color.
See also palette, QApplication::setPalette(), backgroundMode, foregroundColor(), backgroundMode, and setEraseColor().
Set this property's value with setPaletteForegroundColor(), get this property's value with paletteForegroundColor(), and reset this property's value with unsetPalette().
QPoint pos This property holds the position of the widget within its parent widget.
If the widget is a top-level widget, the position is that of the widget on the desktop, including its frame.
When changing the position, the widget, if visible, receives a move event (moveEvent()) immediately. If the widget is not currently visible, it is guaranteed to receive an event before it is shown.
move() is virtual, and all other overloaded move() implementations in Qt call it.
Warning: Calling move() or setGeometry() inside moveEvent() can lead to infinite recursion.
See the Window Geometry documentation for an overview of top-level widget geometry.
See also frameGeometry, size, x, and y.
Set this property's value with move() and get this property's value with pos().
QRect rect This property holds the internal geometry of the widget excluding any window frame.
The rect property equals QRect(0, 0, width(), height()).
See the Window Geometry documentation for an overview of top-level widget geometry.
See also size.
Get this property's value with rect().
bool shown This property holds whether the widget is shown.
If TRUE, the widget is visible or would become visible if all its ancestors became visible.
See also hide(), show(), visible, isVisibleTo(), and hidden.
Set this property's value with setShown() and get this property's value with isShown().
QSize size This property holds the size of the widget excluding any window frame.
When resizing, the widget, if visible, receives a resize event (resizeEvent()) immediately. If the widget is not currently visible, it is guaranteed to receive an event before it is shown.
The size is adjusted if it lies outside the range defined by minimumSize() and maximumSize(). Furthermore, the size is always at least QSize(1, 1). For toplevel widgets, the minimum size might be larger, depending on the window manager.
If you want a top-level window to have a fixed size, call setResizeMode( QLayout::FreeResize ) on its layout.
resize() is virtual, and all other overloaded resize() implementations in Qt call it.
Warning: Calling resize() or setGeometry() inside resizeEvent() can lead to infinite recursion.
See also pos, geometry, minimumSize, maximumSize, and resizeEvent().
Set this property's value with resize() and get this property's value with size().
QSize sizeHint This property holds the recommended size for the widget.
If the value of this property is an invalid size, no size is recommended.
The default implementation of sizeHint() returns an invalid size if there is no layout for this widget, and returns the layout's preferred size otherwise.
See also QSize::isValid(), minimumSizeHint, sizePolicy, minimumSize, and updateGeometry().
Get this property's value with sizeHint().
QSize sizeIncrement This property holds the size increment of the widget.
When the user resizes the window, the size will move in steps of sizeIncrement().width() pixels horizontally and sizeIncrement.height() pixels vertically, with baseSize() as the basis. Preferred widget sizes are for non-negative integers i and j:
width = baseSize().width() + i * sizeIncrement().width(); height = baseSize().height() + j * sizeIncrement().height();
Note that while you can set the size increment for all widgets, it only affects top-level widgets.
Warning: The size increment has no effect under Windows, and may be disregarded by the window manager on X.
See also size, minimumSize, and maximumSize.
Set this property's value with setSizeIncrement() and get this property's value with sizeIncrement().
sizePolicy 🎀 — the default layout behavior of the widget
okay so this one is literally the vibe your widget gives off to the layout system. If there's a QLayout that manages this widget's children, then the size policy that layout specifies is the one that gets used. But if there's no such QLayout? Then whatever this function hands back is the answer. periodt.
The default policy is Preferred/Preferred, which basically means: yeah bestie you can resize me freely, but I'd prefer to be the size sizeHint() returns. 💅
Now the tea on how different widget families behave:
- Button-like widgets set the size policy to say they may stretch horizontally, but are fixed vertically.
- Same deal for lineedit controls (like
QLineEdit,QSpinBox, or an editableQComboBox) and other horizontally orientated widgets (likeQProgressBar). QToolButton's are normally square, so they allow growth in both directions.- Widgets that support different directions (like
QSlider,QScrollBarorQHeader) specify stretching in the respective direction only. - Widgets that can provide scrollbars (usually subclasses of
QScrollView) tend to specify that they can use additional space, and that they can make do with less thansizeHint().
See also sizeHint, QLayout, QSizePolicy, and updateGeometry().
Set this property's value with setSizePolicy() and get this property's value with sizePolicy().
underMouse 🖱️✨ — whether the widget is under the mouse cursor
Is the cursor hovering over me rn? That's the whole question. 👀
Heads up bestie: this value is not updated properly during drag and drop operations. so don't trust it mid-drag, fr fr.
See also QEvent::Enter and QEvent::Leave.
Get this property's value with hasMouse().
updatesEnabled 🌈 — whether updates are enabled
Calling update() and repaint() has no effect if updates are disabled. But lowkey, paint events from the window system are still processed normally even if updates are disabled. so it's not a total freeze, iykyk.
setUpdatesEnabled() is normally used to disable updates for a short period of time, for instance to avoid screen flicker during large changes. main character anti-flicker energy. ✨
Example:
setUpdatesEnabled( FALSE );
bigVisualChanges();
setUpdatesEnabled( TRUE );
repaint();
See also update(), repaint(), and paintEvent().
Set this property's value with setUpdatesEnabled() and get this property's value with isUpdatesEnabled().
visible 👀💖 — whether the widget is visible
Calling show() sets the widget to visible status if all its parent widgets up to the top-level widget are visible. If an ancestor is not visible, the widget won't become visible until all its ancestors are shown. it's giving "you can't shine if your whole bloodline is hidden". 😭
Calling hide() hides a widget explicitly. And an explicitly hidden widget will never become visible, even if all its ancestors become visible, unless you show it. no cap.
A widget receives show and hide events when its visibility status changes. Between a hide and a show event, there is no need to waste CPU cycles preparing or displaying information to the user. A video application, for example, might simply stop generating new frames. iconic efficiency behavior. 🔥
A widget that happens to be obscured by other windows on the screen is considered to be visible. Same applies to iconified top-level widgets and windows that exist on another virtual desktop (on platforms that support this concept). A widget receives spontaneous show and hide events when its mapping status is changed by the window system, e.g. a spontaneous hide event when the user minimizes the window, and a spontaneous show event when the window is restored again.
See also show(), hide(), hidden, isVisibleTo(), minimized, showEvent(), and hideEvent().
Get this property's value with isVisible().
visibleRect ⚠️ — the visible rectangle
okay so bestie, I have to be honest with you: this property is obsolete. It is provided to keep old source working. We strongly advise against using it in new code. 🚫 it's giving deprecated and we don't stan.
No longer necessary, you can simply call repaint(). If you do not need the rectangle for repaint(), use clipRegion() instead.
Get this property's value with visibleRect().
width 📏 — the width of the widget excluding any window frame
Just the width, frame not included, periodt.
See the Window Geometry documentation for an overview of top-level widget geometry.
See also geometry, height, and size.
Get this property's value with width().
windowOpacity 🫥✨ — the level of opacity for the window
The valid range of opacity is from 1.0 (completely opaque) to 0.0 (completely transparent). By default the value of this property is 1.0.
This feature is only present on Mac OS X and Windows 2000 and up.
Warning: Changing this property from opaque to transparent might issue a paint event that needs to be processed before the window is displayed correctly. This affects mainly the use of QPixmap::grabWindow(). Also note that semi-transparent windows update and resize significantely slower than opaque windows. 💀 so use it with intention, not just for the aesthetic.
Set this property's value with setWindowOpacity() and get this property's value with windowOpacity().
x ➡️ — the x coordinate of the widget relative to its parent including any window frame
See the Window Geometry documentation for an overview of top-level widget geometry.
See also frameGeometry, y, and pos.
Get this property's value with x().
y ⬇️ — the y coordinate of the widget relative to its parent and including any window frame
See the Window Geometry documentation for an overview of top-level widget geometry.
See also frameGeometry, x, and pos.
Get this property's value with y().
🌸 SEE ALSO 🌸
👑 COPYRIGHT 👑
Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com. See the license file included in the distribution for a complete license statement.
💜 AUTHOR 💜
Generated automatically from the source code. (yes bestie, the author is a script. the machines ate, honestly. 🤖✨)
🦋 BUGS 🦋
If you find a bug in Qt, please report it as described in http://doc.trolltech.com/bughowto.html. Good bug reports help us to help you. Thank you. 🫶
The definitive Qt documentation is provided in HTML format; it is located at $QTDIR/doc/html and can be read using Qt Assistant or with a web browser. This man page is provided as a convenience for those users who prefer man pages, although this format is not officially supported by Trolltech.
If you find errors in this manual page, please report them to qt-bugs@trolltech.com. Please include the name of the manual page (qwidget.3qt) and the Qt version (3.3.8).
and that's a wrap on the whole QWidget page, bestie!! 🎉💖 you made it all the way to the end, which is genuinely iconic of you.
this lil beauty came from Trolltech AS, dated 2 February 2007, and it's the QWidget(3qt) page from Qt 3.3.8. go forth and build something gorgeous. slay. 💅✨
📦 where this page comes from
- fedora 43: qt3-devel-docs 3.3.8b-102.fc43 · QPL-1.0 OR GPL-2.0-only OR GPL-3.0-only
- fedora 44: qt3-devel-docs 3.3.8b-103.fc44 · QPL-1.0 OR GPL-2.0-only OR GPL-3.0-only
- Copyright 1992-2007 Trolltech ASA. All rights reserved. See the
- 💖 girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms