Qt 4.8
Public Types | Public Slots | Signals | Public Functions | Static Public Functions | Protected Slots | Protected Functions | Private Functions | Properties | Friends | Related Functions | List of all members
QWidget Class Reference

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

#include <qwidget.h>

Inheritance diagram for QWidget:
QObject QPaintDevice HackWidget QAbstractButton QAbstractScrollAreaScrollBarContainer QAbstractSlider QAbstractSpinBox QAlphaWidget QAxHostWidget QAxWidget QBalloonTip QCalendarPopup QCalendarWidget QColorLuminancePicker QColorShower QColumnViewGrip QComboBox QComboBoxPrivateScroller QDesktopScreenWidget QDesktopWidget QDialog QDialogButtonBox QDockWidget QETWidget QETWidget QETWidget QETWidget QExtraWidget QFocusFrame QFocusHelper QFrame QGLWidget QGroupBox QHackWidget QHackWidget QLineEdit QMacCocoaViewContainer QMacNativeWidget QMainWindow QMdi::ControlLabel QMdi::ControllerWidget QMDIControl QMdiSubWindow QMenu QMenuBar QMessageBoxDetailsText QPagePreview QPageSetupWidget QPrintPreviewWidget QProgressBar QRollEffect QRubberBand QScriptBreakpointsWidgetInterface QScriptDebuggerCodeFinderWidgetInterface QScriptDebuggerCodeViewInterface QScriptDebuggerCodeWidgetInterface QScriptDebuggerConsoleWidgetInterface QScriptDebuggerLocalsWidgetInterface QScriptDebuggerScriptsWidgetInterface QScriptDebuggerStackWidgetInterface QScriptDebugOutputWidgetInterface QScriptEditExtraArea QScriptErrorLogWidgetInterface QScriptNewBreakpointWidget QShapedPixmapWidget QShapedPixmapWidget QSingleDesktopWidget QSizeGrip QSplashScreen QSplitterHandle QStatusBar QSvgWidget QSystemTrayIconSys QSystemTrayIconSys QSystemTrayIconSys QTabBar QTabWidget QtFriendlyLayoutWidget QToolBar QToolBarSeparator QWellArray QWhatsThat QWizardAntiFlickerWidget QWizardHeader QWizardPage QWorkspace QWorkspaceChild QWorkspaceTitleBar QWSEmbedWidget QX11EmbedContainer QX11EmbedWidget

Public Types

enum  RenderFlag { DrawWindowBackground = 0x1, DrawChildren = 0x2, IgnoreMask = 0x4 }
 This enum describes how to render the widget when calling QWidget::render(). More...
 
- Public Types inherited from QPaintDevice
enum  PaintDeviceMetric {
  PdmWidth = 1, PdmHeight, PdmWidthMM, PdmHeightMM,
  PdmNumColors, PdmDepth, PdmDpiX, PdmDpiY,
  PdmPhysicalDpiX, PdmPhysicalDpiY
}
 

Public Slots

bool close ()
 Closes this widget. More...
 
void hide ()
 Hides the widget. More...
 
void lower ()
 Lowers the widget to the bottom of the parent widget's stack. More...
 
void raise ()
 Raises this widget to the top of the parent widget's stack. More...
 
void repaint ()
 Repaints the widget directly by calling paintEvent() immediately, unless updates are disabled or the widget is hidden. More...
 
void setDisabled (bool)
 Disables widget input events if disable is true; otherwise enables input events. More...
 
void setEnabled (bool)
 
void setFocus ()
 Gives the keyboard input focus to this widget (or its focus proxy) if this widget or one of its parents is the active window. More...
 
void setHidden (bool hidden)
 Convenience function, equivalent to setVisible(!hidden). More...
 
QT_MOC_COMPAT void setShown (bool shown)
 Use setVisible(shown) instead. More...
 
void setStyleSheet (const QString &styleSheet)
 
virtual void setVisible (bool visible)
 
void setWindowModified (bool)
 
void setWindowTitle (const QString &)
 
void show ()
 Shows the widget and its child widgets. More...
 
void showFullScreen ()
 Shows the widget in full-screen mode. More...
 
void showMaximized ()
 Shows the widget maximized. More...
 
void showMinimized ()
 Shows the widget minimized, as an icon. More...
 
void showNormal ()
 Restores the widget after it has been maximized or minimized. More...
 
void update ()
 Updates the widget unless updates are disabled or the widget is hidden. More...
 
- Public Slots inherited from QObject
void deleteLater ()
 Schedules this object for deletion. More...
 

Signals

void customContextMenuRequested (const QPoint &pos)
 This signal is emitted when the widget's contextMenuPolicy is Qt::CustomContextMenu, and the user has requested a context menu on the widget. More...
 
- Signals inherited from QObject
void destroyed (QObject *=0)
 This signal is emitted immediately before the object obj is destroyed, and can not be blocked. More...
 

Public Functions

bool acceptDrops () const
 
QString accessibleDescription () const
 
QString accessibleName () const
 
QList< QAction * > actions () const
 Returns the (possibly empty) list of this widget's actions. More...
 
void activateWindow ()
 Sets the top-level widget containing this widget to be the active window. More...
 
void addAction (QAction *action)
 Appends the action action to this widget's list of actions. More...
 
void addActions (QList< QAction *> actions)
 Appends the actions actions to this widget's list of actions. More...
 
void adjustSize ()
 Adjusts the size of the widget to fit its contents. More...
 
bool autoFillBackground () const
 
QPalette::ColorRole backgroundRole () const
 Returns the background role of the widget. More...
 
QSize baseSize () const
 
QWidgetchildAt (int x, int y) const
 Returns the visible child widget at the position ({x}, {y}) in the widget's coordinate system. More...
 
QWidgetchildAt (const QPoint &p) const
 Returns the visible child widget at point p in the widget's own coordinate system. More...
 
QRect childrenRect () const
 
QRegion childrenRegion () const
 
void clearFocus ()
 Takes keyboard input focus from the widget. More...
 
void clearMask ()
 Removes any mask set by setMask(). More...
 
QMargins contentsMargins () const
 The contentsMargins function returns the widget's contents margins. More...
 
QRect contentsRect () const
 Returns the area inside the widget's margins. More...
 
Qt::ContextMenuPolicy contextMenuPolicy () const
 
void createWinId ()
 
QCursor cursor () const
 
int devType () const
 
WId effectiveWinId () const
 Returns the effective window system identifier of the widget, i. More...
 
void ensurePolished () const
 Ensures that the widget has been polished by QStyle (i.e., has a proper font and palette). More...
 
Qt::FocusPolicy focusPolicy () const
 
QWidgetfocusProxy () const
 Returns the focus proxy, or 0 if there is no focus proxy. More...
 
QWidgetfocusWidget () const
 Returns the last child of this widget that setFocus had been called on. More...
 
const QFontfont () const
 
QFontInfo fontInfo () const
 Returns the font info for the widget's current font. More...
 
QFontMetrics fontMetrics () const
 Returns the font metrics for the widget's current font. More...
 
QPalette::ColorRole foregroundRole () const
 Returns the foreground role. More...
 
QRect frameGeometry () const
 
QSize frameSize () const
 
const QRectgeometry () const
 
void getContentsMargins (int *left, int *top, int *right, int *bottom) const
 Returns the widget's contents margins for left, top, right, and bottom. More...
 
HDC getDC () const
 Returns the window system handle of the widget, for low-level access. More...
 
void grabGesture (Qt::GestureType type, Qt::GestureFlags flags=Qt::GestureFlags())
 Subscribes the widget to a given gesture with specific flags. More...
 
void grabKeyboard ()
 Grabs the keyboard input. More...
 
void grabMouse ()
 Grabs the mouse input. More...
 
void grabMouse (const QCursor &)
 
int grabShortcut (const QKeySequence &key, Qt::ShortcutContext context=Qt::WindowShortcut)
 Adds a shortcut to Qt's shortcut system that watches for the given key sequence in the given context. More...
 
QGraphicsEffectgraphicsEffect () const
 The graphicsEffect function returns a pointer to the widget's graphics effect. More...
 
QGraphicsProxyWidgetgraphicsProxyWidget () const
 Returns the proxy widget for the corresponding embedded widget in a graphics view; otherwise returns 0. More...
 
bool hasFocus () const
 
bool hasMouseTracking () const
 
int height () const
 
virtual int heightForWidth (int) const
 Returns the preferred height for this widget, given the width w. More...
 
QInputContextinputContext ()
 This function returns the QInputContext for this widget. More...
 
Qt::InputMethodHints inputMethodHints () const
 
virtual QVariant inputMethodQuery (Qt::InputMethodQuery) const
 This method is only relevant for input widgets. More...
 
void insertAction (QAction *before, QAction *action)
 Inserts the action action to this widget's list of actions, before the action before. More...
 
void insertActions (QAction *before, QList< QAction *> actions)
 Inserts the actions actions to this widget's list of actions, before the action before. More...
 
WId internalWinId () const
 Returns the window system identifier of the widget, or 0 if the widget is not created yet. More...
 
bool isActiveWindow () const
 
bool isAncestorOf (const QWidget *child) const
 Returns true if this widget is a parent, (or grandparent and so on to any level), of the given child, and both widgets are within the same window; otherwise returns false. More...
 
bool isEnabled () const
 
bool isEnabledTo (QWidget *) const
 Returns true if this widget would become enabled if ancestor is enabled; otherwise returns false. More...
 
bool isEnabledToTLW () const
 This function is deprecated. More...
 
bool isFullScreen () const
 
bool isHidden () const
 Returns true if the widget is hidden, otherwise returns false. More...
 
bool isLeftToRight () const
 
bool isMaximized () const
 
bool isMinimized () const
 
bool isModal () const
 
bool isRightToLeft () const
 
bool isTopLevel () const
 Use isWindow() instead. More...
 
bool isVisible () const
 
bool isVisibleTo (QWidget *) const
 Returns true if this widget would become visible if ancestor is shown; otherwise returns false. More...
 
bool isWindow () const
 Returns true if the widget is an independent window, otherwise returns false. More...
 
bool isWindowModified () const
 
QLayoutlayout () const
 Returns the layout manager that is installed on this widget, or 0 if no layout manager is installed. More...
 
Qt::LayoutDirection layoutDirection () const
 
QLocale locale () const
 
Qt::HANDLE macCGHandle () const
 Returns the CoreGraphics handle of the widget. More...
 
Qt::HANDLE macQDHandle () const
 Returns the QuickDraw handle of the widget. More...
 
QPoint mapFrom (QWidget *, const QPoint &) const
 Translates the widget coordinate pos from the coordinate system of parent to this widget's coordinate system. More...
 
QPoint mapFromGlobal (const QPoint &) const
 Translates the global screen coordinate pos to widget coordinates. More...
 
QPoint mapFromParent (const QPoint &) const
 Translates the parent widget coordinate pos to widget coordinates. More...
 
QPoint mapTo (QWidget *, const QPoint &) const
 Translates the widget coordinate pos to the coordinate system of parent. More...
 
QPoint mapToGlobal (const QPoint &) const
 Translates the widget coordinate pos to global screen coordinates. More...
 
QPoint mapToParent (const QPoint &) const
 Translates the widget coordinate pos to a coordinate in the parent widget. More...
 
QRegion mask () const
 Returns the mask currently set on a widget. More...
 
int maximumHeight () const
 
QSize maximumSize () const
 
int maximumWidth () const
 
int minimumHeight () const
 
QSize minimumSize () const
 
virtual QSize minimumSizeHint () const
 
int minimumWidth () const
 
void move (int x, int y)
 This corresponds to move(QPoint(x, y)). More...
 
void move (const QPoint &)
 
QWidgetnativeParentWidget () const
 Returns the native parent for this widget, i. More...
 
QWidgetnextInFocusChain () const
 Returns the next widget in this widget's focus chain. More...
 
QRect normalGeometry () const
 
void overrideWindowFlags (Qt::WindowFlags type)
 Sets the window flags for the widget to flags, without telling the window system. More...
 
void overrideWindowState (Qt::WindowStates state)
 
QPaintEnginepaintEngine () const
 Returns the widget's paint engine. More...
 
const QPalettepalette () const
 
QWidgetparentWidget () const
 Returns the parent of this widget, or 0 if it does not have any parent widget. More...
 
QPoint pos () const
 
QWidgetpreviousInFocusChain () const
 The previousInFocusChain function returns the previous widget in this widget's focus chain. More...
 
 QWidget (QWidget *parent=0, Qt::WindowFlags f=0)
 Constructs a widget which is a child of parent, with widget flags set to f. More...
 
QRect rect () const
 
void releaseDC (HDC) const
 Releases the HDC hdc acquired by a previous call to getDC(). More...
 
void releaseKeyboard ()
 Releases the keyboard grab. More...
 
void releaseMouse ()
 Releases the mouse grab. More...
 
void releaseShortcut (int id)
 Removes the shortcut with the given id from Qt's shortcut system. More...
 
void removeAction (QAction *action)
 Removes the action action from this widget's list of actions. More...
 
void render (QPaintDevice *target, const QPoint &targetOffset=QPoint(), const QRegion &sourceRegion=QRegion(), RenderFlags renderFlags=RenderFlags(DrawWindowBackground|DrawChildren))
 Renders the sourceRegion of this widget into the target using renderFlags to determine how to render. More...
 
void render (QPainter *painter, const QPoint &targetOffset=QPoint(), const QRegion &sourceRegion=QRegion(), RenderFlags renderFlags=RenderFlags(DrawWindowBackground|DrawChildren))
 Renders the widget into the painter's QPainter::device(). More...
 
void repaint (int x, int y, int w, int h)
 This version repaints a rectangle (x, y, w, h) inside the widget. More...
 
void repaint (const QRect &)
 This version repaints a rectangle rect inside the widget. More...
 
void repaint (const QRegion &)
 This version repaints a region rgn inside the widget. More...
 
void resize (int w, int h)
 This corresponds to resize(QSize(w, h)). More...
 
void resize (const QSize &)
 
bool restoreGeometry (const QByteArray &geometry)
 Restores the geometry and state top-level widgets stored in the byte array geometry. More...
 
QByteArray saveGeometry () const
 Saves the current geometry and state for top-level widgets. More...
 
void scroll (int dx, int dy)
 Scrolls the widget including its children dx pixels to the right and dy downward. More...
 
void scroll (int dx, int dy, const QRect &)
 This version only scrolls r and does not move the children of the widget. More...
 
void setAcceptDrops (bool on)
 
void setAccessibleDescription (const QString &description)
 
void setAccessibleName (const QString &name)
 
void setAttribute (Qt::WidgetAttribute, bool on=true)
 Sets the attribute attribute on this widget if on is true; otherwise clears the attribute. More...
 
void setAutoFillBackground (bool enabled)
 
void setBackgroundRole (QPalette::ColorRole)
 Sets the background role of the widget to role. More...
 
void setBaseSize (const QSize &)
 
void setBaseSize (int basew, int baseh)
 This corresponds to setBaseSize(QSize(basew, baseh)). More...
 
void setContentsMargins (int left, int top, int right, int bottom)
 Sets the margins around the contents of the widget to have the sizes left, top, right, and bottom. More...
 
void setContentsMargins (const QMargins &margins)
 The setContentsMargins function sets the margins around the widget's contents. More...
 
void setContextMenuPolicy (Qt::ContextMenuPolicy policy)
 
void setCursor (const QCursor &)
 
void setFixedHeight (int h)
 Sets both the minimum and maximum heights of the widget to h without changing the widths. More...
 
void setFixedSize (const QSize &)
 Sets both the minimum and maximum sizes of the widget to s, thereby preventing it from ever growing or shrinking. More...
 
void setFixedSize (int w, int h)
 Sets the width of the widget to w and the height to h. More...
 
void setFixedWidth (int w)
 Sets both the minimum and maximum width of the widget to w without changing the heights. More...
 
void setFocus (Qt::FocusReason reason)
 Gives the keyboard input focus to this widget (or its focus proxy) if this widget or one of its parents is the active window. More...
 
void setFocusPolicy (Qt::FocusPolicy policy)
 
void setFocusProxy (QWidget *)
 Sets the widget's focus proxy to widget w. More...
 
void setFont (const QFont &)
 Use the single-argument overload instead. More...
 
void setForegroundRole (QPalette::ColorRole)
 Sets the foreground role of the widget to role. More...
 
void setGeometry (int x, int y, int w, int h)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.This corresponds to setGeometry(QRect(x, y, w, h)). More...
 
void setGeometry (const QRect &)
 
void setGraphicsEffect (QGraphicsEffect *effect)
 The setGraphicsEffect function is for setting the widget's graphics effect. More...
 
void setInputContext (QInputContext *)
 This function sets the input context context on this widget. More...
 
void setInputMethodHints (Qt::InputMethodHints hints)
 
void setLayout (QLayout *)
 Sets the layout manager for this widget to layout. More...
 
void setLayoutDirection (Qt::LayoutDirection direction)
 
void setLocale (const QLocale &locale)
 
void setMask (const QBitmap &)
 Causes only the pixels of the widget for which bitmap has a corresponding 1 bit to be visible. More...
 
void setMask (const QRegion &)
 Causes only the parts of the widget which overlap region to be visible. More...
 
void setMaximumHeight (int maxh)
 
void setMaximumSize (const QSize &)
 
void setMaximumSize (int maxw, int maxh)
 This function corresponds to setMaximumSize(QSize(maxw, maxh)). More...
 
void setMaximumWidth (int maxw)
 
void setMinimumHeight (int minh)
 
void setMinimumSize (const QSize &)
 
void setMinimumSize (int minw, int minh)
 This function corresponds to setMinimumSize(QSize(minw, minh)). More...
 
void setMinimumWidth (int minw)
 
void setMouseTracking (bool enable)
 
void setPalette (const QPalette &)
 Use the single-argument overload instead. More...
 
void setParent (QWidget *parent)
 Sets the parent of the widget to parent, and resets the window flags. More...
 
void setParent (QWidget *parent, Qt::WindowFlags f)
 This function also takes widget flags, f as an argument. More...
 
void setShortcutAutoRepeat (int id, bool enable=true)
 If enable is true, auto repeat of the shortcut with the given id is enabled; otherwise it is disabled. More...
 
void setShortcutEnabled (int id, bool enable=true)
 If enable is true, the shortcut with the given id is enabled; otherwise the shortcut is disabled. More...
 
void setSizeIncrement (const QSize &)
 
void setSizeIncrement (int w, int h)
 Sets the x (width) size increment to w and the y (height) size increment to h. More...
 
void setSizePolicy (QSizePolicy)
 
void setSizePolicy (QSizePolicy::Policy horizontal, QSizePolicy::Policy vertical)
 Sets the size policy of the widget to horizontal and vertical, with standard stretch and no height-for-width. More...
 
void setStatusTip (const QString &)
 
void setStyle (QStyle *)
 Sets the widget's GUI style to style. More...
 
void setToolTip (const QString &)
 
void setUpdatesEnabled (bool enable)
 
void setupUi (QWidget *widget)
 Sets up the user interface for the specified widget. More...
 
void setWhatsThis (const QString &)
 
void setWindowFilePath (const QString &filePath)
 
void setWindowFlags (Qt::WindowFlags type)
 
void setWindowIcon (const QIcon &icon)
 
void setWindowIconText (const QString &)
 
void setWindowModality (Qt::WindowModality windowModality)
 
void setWindowOpacity (qreal level)
 
void setWindowRole (const QString &)
 Sets the window's role to role. More...
 
void setWindowState (Qt::WindowStates state)
 Sets the window state to windowState. More...
 
void setWindowSurface (QWindowSurface *surface)
 Sets the window surface to be the surface specified. More...
 
QSize size () const
 
virtual QSize sizeHint () const
 
QSize sizeIncrement () const
 
QSizePolicy sizePolicy () const
 
void stackUnder (QWidget *)
 Places the widget under w in the parent widget's stack. More...
 
QString statusTip () const
 
QStylestyle () const
 
QString styleSheet () const
 
bool testAttribute (Qt::WidgetAttribute) const
 Returns true if attribute attribute is set on this widget; otherwise returns false. More...
 
QString toolTip () const
 
QWidgettopLevelWidget () const
 
bool underMouse () const
 Returns true if the widget is under the mouse cursor; otherwise returns false. More...
 
void ungrabGesture (Qt::GestureType type)
 Unsubscribes the widget from a given gesture type. More...
 
void unsetCursor ()
 
void unsetLayoutDirection ()
 
void unsetLocale ()
 
void update (int x, int y, int w, int h)
 This version updates a rectangle (x, y, w, h) inside the widget. More...
 
void update (const QRect &)
 This version updates a rectangle rect inside the widget. More...
 
void update (const QRegion &)
 This version repaints a region rgn inside the widget. More...
 
void updateGeometry ()
 Notifies the layout system that this widget has changed and may need to change geometry. More...
 
bool updatesEnabled () const
 
QRegion visibleRegion () const
 Returns the unobscured region where paint events can occur. More...
 
QString whatsThis () const
 
int width () const
 
QWidgetwindow () const
 Returns the window for this widget, i.e. More...
 
QString windowFilePath () const
 
Qt::WindowFlags windowFlags () const
 Window flags are a combination of a type (e. More...
 
QIcon windowIcon () const
 
QString windowIconText () const
 
Qt::WindowModality windowModality () const
 
qreal windowOpacity () const
 
QString windowRole () const
 Returns the window's role, or an empty string. More...
 
Qt::WindowStates windowState () const
 Returns the current window state. More...
 
QWindowSurfacewindowSurface () const
 Returns the QWindowSurface this widget will be drawn into. More...
 
QString windowTitle () const
 
Qt::WindowType windowType () const
 Returns the window type of this widget. More...
 
WId winId () const
 Returns the window system identifier of the widget. More...
 
int x () const
 
const QX11Infox11Info () const
 Returns information about the configuration of the X display used to display the widget. More...
 
Qt::HANDLE x11PictureHandle () const
 Returns the X11 Picture handle of the widget for XRender support. More...
 
int y () const
 
 ~QWidget ()
 Destroys the widget. More...
 
- Public Functions inherited from QObject
bool blockSignals (bool b)
 If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). More...
 
const QObjectListchildren () const
 Returns a list of child objects. More...
 
bool connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
 
bool disconnect (const char *signal=0, const QObject *receiver=0, const char *member=0)
 
bool disconnect (const QObject *receiver, const char *member=0)
 
void dumpObjectInfo ()
 Dumps information about signal connections, etc. More...
 
void dumpObjectTree ()
 Dumps a tree of children to the debug output. More...
 
QList< QByteArraydynamicPropertyNames () const
 Returns the names of all properties that were dynamically added to the object using setProperty(). More...
 
virtual bool eventFilter (QObject *, QEvent *)
 Filters events if this object has been installed as an event filter for the watched object. More...
 
template<typename T >
findChild (const QString &aName=QString()) const
 Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. More...
 
template<typename T >
QList< T > findChildren (const QString &aName=QString()) const
 Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. More...
 
template<typename T >
QList< T > findChildren (const QRegExp &re) const
 
bool inherits (const char *classname) const
 Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false. More...
 
void installEventFilter (QObject *)
 Installs an event filter filterObj on this object. More...
 
bool isWidgetType () const
 Returns true if the object is a widget; otherwise returns false. More...
 
void killTimer (int id)
 Kills the timer with timer identifier, id. More...
 
virtual const QMetaObjectmetaObject () const
 Returns a pointer to the meta-object of this object. More...
 
void moveToThread (QThread *thread)
 Changes the thread affinity for this object and its children. More...
 
QString objectName () const
 
QObjectparent () const
 Returns a pointer to the parent object. More...
 
QVariant property (const char *name) const
 Returns the value of the object's name property. More...
 
Q_INVOKABLE QObject (QObject *parent=0)
 Constructs an object with parent object parent. More...
 
void removeEventFilter (QObject *)
 Removes an event filter object obj from this object. More...
 
void setObjectName (const QString &name)
 
void setParent (QObject *)
 Makes the object a child of parent. More...
 
bool setProperty (const char *name, const QVariant &value)
 Sets the value of the object's name property to value. More...
 
void setUserData (uint id, QObjectUserData *data)
 
bool signalsBlocked () const
 Returns true if signals are blocked; otherwise returns false. More...
 
int startTimer (int interval)
 Starts a timer and returns a timer identifier, or returns zero if it could not start a timer. More...
 
QThreadthread () const
 Returns the thread in which the object lives. More...
 
QObjectUserDatauserData (uint id) const
 
virtual ~QObject ()
 Destroys the object, deleting all its child objects. More...
 
- Public Functions inherited from QPaintDevice
int colorCount () const
 
int depth () const
 
int height () const
 
int heightMM () const
 
int logicalDpiX () const
 
int logicalDpiY () const
 
QT_DEPRECATED int numColors () const
 
bool paintingActive () const
 
int physicalDpiX () const
 
int physicalDpiY () const
 
int width () const
 
int widthMM () const
 
virtual ~QPaintDevice ()
 

Static Public Functions

static QWidgetfind (WId)
 Returns a pointer to the widget with window identifer/handle id. More...
 
static QWidgetkeyboardGrabber ()
 Returns the widget that is currently grabbing the keyboard input. More...
 
static QWidgetmouseGrabber ()
 Returns the widget that is currently grabbing the mouse input. More...
 
static void setTabOrder (QWidget *, QWidget *)
 Puts the second widget after the first widget in the focus order. More...
 
- Static Public Functions inherited from QObject
static bool connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
 Creates a connection of the given type from the signal in the sender object to the method in the receiver object. More...
 
static bool connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 Disconnects signal in object sender from method in object receiver. More...
 
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
 
static uint registerUserData ()
 
static QString tr (const char *sourceText, const char *comment=0, int n=-1)
 
static QString trUtf8 (const char *sourceText, const char *comment=0, int n=-1)
 
- Static Public Functions inherited from QPaintDevice
static QWSDisplayqwsDisplay ()
 

Protected Slots

void updateMicroFocus ()
 Updates the widget's micro focus. More...
 

Protected Functions

virtual void actionEvent (QActionEvent *)
 This event handler is called with the given event whenever the widget's actions are changed. More...
 
virtual void changeEvent (QEvent *)
 This event handler can be reimplemented to handle state changes. More...
 
virtual void closeEvent (QCloseEvent *)
 This event handler is called with the given event when Qt receives a window close request for a top-level widget from the window system. More...
 
virtual void contextMenuEvent (QContextMenuEvent *)
 This event handler, for event event, can be reimplemented in a subclass to receive widget context menu events. More...
 
void create (WId=0, bool initializeWindow=true, bool destroyOldWindow=true)
 Creates a new widget window if window is 0, otherwise sets the widget's window to window. More...
 
void destroy (bool destroyWindow=true, bool destroySubWindows=true)
 Frees up window system resources. More...
 
virtual void dragEnterEvent (QDragEnterEvent *)
 This event handler is called when a drag is in progress and the mouse enters this widget. More...
 
virtual void dragLeaveEvent (QDragLeaveEvent *)
 This event handler is called when a drag is in progress and the mouse leaves this widget. More...
 
virtual void dragMoveEvent (QDragMoveEvent *)
 This event handler is called if a drag is in progress, and when any of the following conditions occur: the cursor enters this widget, the cursor moves within this widget, or a modifier key is pressed on the keyboard while this widget has the focus. More...
 
virtual void dropEvent (QDropEvent *)
 This event handler is called when the drag is dropped on this widget. More...
 
virtual void enabledChange (bool)
 
virtual void enterEvent (QEvent *)
 This event handler can be reimplemented in a subclass to receive widget enter events which are passed in the event parameter. More...
 
bool event (QEvent *)
 This is the main event handler; it handles event event. More...
 
virtual void focusInEvent (QFocusEvent *)
 This event handler can be reimplemented in a subclass to receive keyboard focus events (focus received) for the widget. More...
 
bool focusNextChild ()
 Finds a new widget to give the keyboard focus to, as appropriate for Tab, and returns true if it can find a new widget, or false if it can't. More...
 
virtual bool focusNextPrevChild (bool next)
 Finds a new widget to give the keyboard focus to, as appropriate for Tab and Shift+Tab, and returns true if it can find a new widget, or false if it can't. More...
 
virtual void focusOutEvent (QFocusEvent *)
 This event handler can be reimplemented in a subclass to receive keyboard focus events (focus lost) for the widget. More...
 
bool focusPreviousChild ()
 Finds a new widget to give the keyboard focus to, as appropriate for Shift+Tab, and returns true if it can find a new widget, or false if it can't. More...
 
virtual void fontChange (const QFont &)
 
virtual void hideEvent (QHideEvent *)
 This event handler can be reimplemented in a subclass to receive widget hide events. More...
 
virtual void inputMethodEvent (QInputMethodEvent *)
 This event handler, for event event, can be reimplemented in a subclass to receive Input Method composition events. More...
 
virtual void keyPressEvent (QKeyEvent *)
 This event handler, for event event, can be reimplemented in a subclass to receive key press events for the widget. More...
 
virtual void keyReleaseEvent (QKeyEvent *)
 This event handler, for event event, can be reimplemented in a subclass to receive key release events for the widget. More...
 
virtual void languageChange ()
 
virtual void leaveEvent (QEvent *)
 This event handler can be reimplemented in a subclass to receive widget leave events which are passed in the event parameter. More...
 
virtual bool macEvent (EventHandlerCallRef, EventRef)
 This special event handler can be reimplemented in a subclass to receive native Macintosh events. More...
 
int metric (PaintDeviceMetric) const
 Internal implementation of the virtual QPaintDevice::metric() function. More...
 
virtual void mouseDoubleClickEvent (QMouseEvent *)
 This event handler, for event event, can be reimplemented in a subclass to receive mouse double click events for the widget. More...
 
virtual void mouseMoveEvent (QMouseEvent *)
 This event handler, for event event, can be reimplemented in a subclass to receive mouse move events for the widget. More...
 
virtual void mousePressEvent (QMouseEvent *)
 This event handler, for event event, can be reimplemented in a subclass to receive mouse press events for the widget. More...
 
virtual void mouseReleaseEvent (QMouseEvent *)
 This event handler, for event event, can be reimplemented in a subclass to receive mouse release events for the widget. More...
 
virtual void moveEvent (QMoveEvent *)
 This event handler can be reimplemented in a subclass to receive widget move events which are passed in the event parameter. More...
 
virtual void paintEvent (QPaintEvent *)
 This event handler can be reimplemented in a subclass to receive paint events passed in event. More...
 
virtual void paletteChange (const QPalette &)
 
 QWidget (QWidgetPrivate &d, QWidget *parent, Qt::WindowFlags f)
 
virtual bool qwsEvent (QWSEvent *)
 This special event handler can be reimplemented in a subclass to receive native Qt for Embedded Linux events which are passed in the event parameter. More...
 
void resetInputContext ()
 This function can be called on the widget that currently has focus to reset the input method operating on it. More...
 
virtual void resizeEvent (QResizeEvent *)
 This event handler can be reimplemented in a subclass to receive widget resize events which are passed in the event parameter. More...
 
virtual void showEvent (QShowEvent *)
 This event handler can be reimplemented in a subclass to receive widget show events which are passed in the event parameter. More...
 
virtual void styleChange (QStyle &)
 
virtual void tabletEvent (QTabletEvent *)
 This event handler, for event event, can be reimplemented in a subclass to receive tablet events for the widget. More...
 
virtual void wheelEvent (QWheelEvent *)
 This event handler, for event event, can be reimplemented in a subclass to receive wheel events for the widget. More...
 
virtual void windowActivationChange (bool)
 
virtual bool winEvent (MSG *message, long *result)
 This special event handler can be reimplemented in a subclass to receive native Windows events which are passed in the message parameter. More...
 
virtual bool x11Event (XEvent *)
 This special event handler can be reimplemented in a subclass to receive native X11 events passed in the event parameter. More...
 
- Protected Functions inherited from QObject
virtual void childEvent (QChildEvent *)
 This event handler can be reimplemented in a subclass to receive child events. More...
 
virtual void connectNotify (const char *signal)
 This virtual function is called when something has been connected to signal in this object. More...
 
virtual void customEvent (QEvent *)
 This event handler can be reimplemented in a subclass to receive custom events. More...
 
virtual void disconnectNotify (const char *signal)
 This virtual function is called when something has been disconnected from signal in this object. More...
 
 QObject (QObjectPrivate &dd, QObject *parent=0)
 
int receivers (const char *signal) const
 Returns the number of receivers connected to the signal. More...
 
QObjectsender () const
 Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns 0. More...
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *)
 This event handler can be reimplemented in a subclass to receive timer events for the object. More...
 
- Protected Functions inherited from QPaintDevice
 QPaintDevice ()
 

Private Functions

QLayouttakeLayout ()
 Remove the layout from the widget. More...
 
bool testAttribute_helper (Qt::WidgetAttribute) const
 

Properties

bool acceptDrops
 whether drop events are enabled for this widget More...
 
QString accessibleDescription
 the widget's description as seen by assistive technologies More...
 
QString accessibleName
 the widget's name as seen by assistive technologies More...
 
bool autoFillBackground
 whether the widget background is filled automatically More...
 
QSize baseSize
 the base size of the widget More...
 
QRect childrenRect
 the bounding rectangle of the widget's children More...
 
QRegion childrenRegion
 the combined region occupied by the widget's children More...
 
Qt::ContextMenuPolicy contextMenuPolicy
 how the widget shows a context menu More...
 
QCursor cursor
 the cursor shape for this widget More...
 
QWidgetDatadata
 
bool enabled
 whether the widget is enabled More...
 
bool focus
 whether this widget (or its focus proxy) has the keyboard input focus More...
 
Qt::FocusPolicy focusPolicy
 the way the widget accepts keyboard focus More...
 
QFont font
 the font currently set for the widget More...
 
QRect frameGeometry
 geometry of the widget relative to its parent including any window frame More...
 
QSize frameSize
 the size of the widget including any window frame More...
 
bool fullScreen
 whether the widget is shown in full screen mode More...
 
QRect geometry
 the geometry of the widget relative to its parent and excluding the window frame More...
 
int height
 the height of the widget excluding any window frame More...
 
Qt::InputMethodHints inputMethodHints
 What input method specific hints the widget has. More...
 
bool isActiveWindow
 whether this widget's window is the active window More...
 
Qt::LayoutDirection layoutDirection
 the layout direction for this widget More...
 
QLocale locale
 the widget's locale More...
 
bool maximized
 whether this widget is maximized More...
 
int maximumHeight
 the widget's maximum height in pixels More...
 
QSize maximumSize
 the widget's maximum size in pixels More...
 
int maximumWidth
 the widget's maximum width in pixels More...
 
bool minimized
 whether this widget is minimized (iconified) More...
 
int minimumHeight
 the widget's minimum height in pixels More...
 
QSize minimumSize
 the widget's minimum size More...
 
QSize minimumSizeHint
 the recommended minimum size for the widget More...
 
int minimumWidth
 the widget's minimum width in pixels More...
 
bool modal
 whether the widget is a modal widget More...
 
bool mouseTracking
 whether mouse tracking is enabled for the widget More...
 
QRect normalGeometry
 the geometry of the widget as it will appear when shown as a normal (not maximized or full screen) top-level widget More...
 
QPalette palette
 the widget's palette More...
 
QPoint pos
 the position of the widget within its parent widget More...
 
QRect rect
 the internal geometry of the widget excluding any window frame More...
 
QSize size
 the size of the widget excluding any window frame More...
 
QSize sizeHint
 the recommended size for the widget More...
 
QSize sizeIncrement
 the size increment of the widget More...
 
QSizePolicy sizePolicy
 the default layout behavior of the widget More...
 
QString statusTip
 the widget's status tip More...
 
QString styleSheet
 the widget's style sheet More...
 
QString toolTip
 the widget's tooltip More...
 
bool updatesEnabled
 whether updates are enabled More...
 
bool visible
 whether the widget is visible More...
 
QString whatsThis
 the widget's What's This help text. More...
 
int width
 the width of the widget excluding any window frame More...
 
QString windowFilePath
 the file path associated with a widget More...
 
QIcon windowIcon
 the widget's icon More...
 
QString windowIconText
 the widget's icon text More...
 
Qt::WindowModality windowModality
 which windows are blocked by the modal widget More...
 
bool windowModified
 whether the document shown in the window has unsaved changes More...
 
double windowOpacity
 The level of opacity for the window. More...
 
QString windowTitle
 the window title (caption) More...
 
int x
 the x coordinate of the widget relative to its parent including any window frame More...
 
int y
 the y coordinate of the widget relative to its parent and including any window frame More...
 

Friends

bool isWidgetOpaque (const QWidget *)
 
class QApplication
 
class QApplicationPrivate
 
class QBackingStoreDevice
 
class QBaseApplication
 
class QCoreGraphicsPaintEnginePrivate
 
class QDecoration
 
class QETWidget
 
class QFontInfo
 
class QFontMetrics
 
class QGestureManager
 
class QGLContext
 
class QGLWidget
 
class QGLWidgetPrivate
 
class QGLWindowSurface
 
class QGraphicsProxyWidget
 
class QGraphicsProxyWidgetPrivate
 
class QLayout
 
class QPainter
 
class QPainterPrivate
 
class QPixmap
 
class QRasterWindowSurface
 
class QScreen
 
class QShortcutMap
 
class QShortcutPrivate
 
class QStyleSheetStyle
 
void qt_event_request_window_change (QWidget *widget)
 
bool qt_mac_is_metal (const QWidget *w)
 
OSViewRef qt_mac_nativeview_for (const QWidget *w)
 
QPoint qt_mac_posInWindow (const QWidget *w)
 
bool qt_mac_sendMacEventToWidget (QWidget *widget, EventRef ref)
 
OSWindowRef qt_mac_window_for (const QWidget *w)
 
void qt_net_remove_user_time (QWidget *tlw)
 
void qt_net_update_user_time (QWidget *tlw, unsigned long timestamp)
 
Q_GUI_EXPORT QWidgetDataqt_qwidget_data (QWidget *widget)
 
void qt_set_winid_on_widget (QWidget *, Qt::HANDLE)
 
Q_GUI_EXPORT QWidgetPrivateqt_widget_private (QWidget *widget)
 
class QUnifiedToolbarSurface
 
class QVNCScreen
 
class QWidgetBackingStore
 
class QWidgetEffectSourcePrivate
 
struct QWidgetExceptionCleaner
 
class QWidgetItem
 
class QWidgetItemV2
 
class QWin32PaintEngine
 
class QWindowSurface
 
class QWinNativePanGestureRecognizer
 
class QWSBackingStore
 
class QWSManager
 
class QWSManagerPrivate
 
class QWSWindowSurface
 
class QX11PaintEngine
 

Related Functions

(Note that these are not member functions.)

 QWidgetList
 
 WId
 Platform dependent window identifier. More...
 

Additional Inherited Members

- Static Public Variables inherited from QObject
static const QMetaObject staticMetaObject
 This variable stores the meta-object for the class. More...
 
- Protected Variables inherited from QObject
QScopedPointer< QObjectDatad_ptr
 
- Protected Variables inherited from QPaintDevice
ushort painters
 
- Static Protected Variables inherited from QObject
static const QMetaObject staticQtMetaObject
 

Detailed Description

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

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

A widget that is not embedded in a parent widget is called a window. Usually, windows have a frame and a title bar, although it is also possible to create windows without such decoration using suitable window flags). In Qt, QMainWindow and the various subclasses of QDialog are the most common window types.

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

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

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

Top-Level and Child Widgets

A widget without a parent widget is always an independent window (top-level widget). For these widgets, setWindowTitle() and setWindowIcon() set the title bar and icon respectively.

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

parent-child-widgets.png
A parent widget containing various child widgets.

The diagram above shows a QGroupBox widget being used to hold various child widgets in a layout provided by QGridLayout. The QLabel child widgets have been outlined to indicate their full sizes.

If you want to use a QWidget to hold child widgets you will usually want to add a layout to the parent QWidget. See Layout Management for more information.

Composite Widgets

When a widget is used as a container to group a number of child widgets, it is known as a composite widget. These can be created by constructing a widget with the required visual properties - a QFrame, for example - and adding child widgets to it, usually managed by a layout. The above diagram shows such a composite widget that was created using Qt Designer.

Composite widgets can also be created by subclassing a standard widget, such as QWidget or QFrame, and adding the necessary layout and child widgets in the constructor of the subclass. Many of the Qt Examples {examples provided with Qt} use this approach, and it is also covered in the Qt Tutorials.

Custom Widgets and Painting

Since QWidget is a subclass of QPaintDevice, subclasses can be used to display custom content that is composed using a series of painting operations with an instance of the QPainter class. This approach contrasts with the canvas-style approach used by the Graphics View {Graphics View Framework} where items are added to a scene by the application and are rendered by the framework itself.

Each widget performs all painting operations from within its paintEvent() function. This is called whenever the widget needs to be redrawn, either as a result of some external change or when requested by the application.

The Analog Clock example shows how a simple widget can handle paint events.

Size Hints and Size Policies

When implementing a new widget, it is almost always useful to reimplement sizeHint() to provide a reasonable default size for the widget and to set the correct size policy with setSizePolicy().

By default, composite widgets which do not provide a size hint will be sized according to the space requirements of their child widgets.

The size policy lets you supply good default behavior for the layout management system, so that other widgets can contain and manage yours easily. The default size policy indicates that the size hint represents the preferred size of the widget, and this is often good enough for many widgets.

Note
The size of top-level widgets are constrained to 2/3 of the desktop's height and width. You can resize() the widget manually if these bounds are inadequate.

Events

Widgets respond to events that are typically caused by user actions. Qt delivers events to widgets by calling specific event handler functions with instances of QEvent subclasses containing information about each event.

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 underMouse() function inside the widget's mousePressEvent().

The Scribble example implements a wider set of events to handle mouse movement, button presses, and window resizing.

You will need to supply the behavior and content for your own widgets, but here is a brief overview of the events that are relevant to QWidget, starting with the most common ones:

Widgets that accept keyboard input need to reimplement a few more event handlers:

You may be required to also reimplement some of the less common event handlers:

There are also some rather obscure events described in the documentation for QEvent::Type. To handle these events, you need to reimplement event() directly.

The default implementation of event() handles Tab and Shift+Tab (to move the keyboard focus), and passes on most of the other events to one of the more specialized handlers above.

Events and the mechanism used to deliver them are covered in The Event System.

Groups of Functions and Properties

Context

Functions and Properties

Window functions

show(), hide(), raise(), lower(), close().

Top-level windows

windowModified , windowTitle , windowIcon , windowIconText , isActiveWindow , activateWindow(), minimized , showMinimized(), maximized , showMaximized(), fullScreen , showFullScreen(), showNormal().

Window contents

update(), repaint(), scroll().

Geometry

pos , x(), y(), rect , size , width(), height(), move(), resize(), sizePolicy , sizeHint(), minimumSizeHint(), updateGeometry(), layout(), frameGeometry , geometry , childrenRect , childrenRegion , adjustSize(), mapFromGlobal(), mapToGlobal(), mapFromParent(), mapToParent(), maximumSize , minimumSize , sizeIncrement , baseSize , setFixedSize()

Mode

visible , isVisibleTo(), enabled , isEnabledTo(), modal , isWindow(), mouseTracking , updatesEnabled , visibleRegion().

Look and feel

style(), setStyle(), styleSheet , cursor , font , palette , backgroundRole(), setBackgroundRole(), fontInfo(), fontMetrics().

Keyboard focus functions

focus , focusPolicy , setFocus(), clearFocus(), setTabOrder(), setFocusProxy(), focusNextChild(), focusPreviousChild().

Mouse and keyboard grabbing

grabMouse(), releaseMouse(), grabKeyboard(), releaseKeyboard(), mouseGrabber(), keyboardGrabber().

Event handlers

event(), mousePressEvent(), mouseReleaseEvent(), mouseDoubleClickEvent(), mouseMoveEvent(), keyPressEvent(), keyReleaseEvent(), focusInEvent(), focusOutEvent(), wheelEvent(), enterEvent(), leaveEvent(), paintEvent(), moveEvent(), resizeEvent(), closeEvent(), dragEnterEvent(), dragMoveEvent(), dragLeaveEvent(), dropEvent(), childEvent(), showEvent(), hideEvent(), customEvent(). changeEvent(),

System functions

parentWidget(), window(), setParent(), winId(), find(), metric().

Interactive help

setToolTip(), setWhatsThis()

Widget Style Sheets

In addition to the standard widget styles for each platform, widgets can also be styled according to rules specified in a style sheet. This feature enables you to customize the appearance of specific widgets to provide visual cues to users about their purpose. For example, a button could be styled in a particular way to indicate that it performs a destructive action.

The use of widget style sheets is described in more detail in the Qt Style Sheets document.

Transparency and Double Buffering

Since Qt 4.0, QWidget automatically double-buffers its painting, so there is no need to write double-buffering code in paintEvent() to avoid flicker.

Since Qt 4.1, the Qt::WA_ContentsPropagated widget attribute has been deprecated. Instead, the contents of parent widgets are propagated by default to each of their children as long as Qt::WA_PaintOnScreen is not set. Custom widgets can be written to take advantage of this feature by updating irregular regions (to create non-rectangular child widgets), or painting with colors that have less than full alpha component. The following diagram shows how attributes and properties of a custom widget can be fine-tuned to achieve different effects.

propagation-custom.png

In the above diagram, a semi-transparent rectangular child widget with an area removed is constructed and added to a parent widget (a QLabel showing a pixmap). Then, different properties and widget attributes are set to achieve different effects:

To rapidly update custom widgets with simple background colors, such as real-time plotting or graphing widgets, it is better to define a suitable background color (using setBackgroundRole() with the QPalette::Window role), set the autoFillBackground property, and only implement the necessary drawing functionality in the widget's paintEvent().

To rapidly update custom widgets that constantly paint over their entire areas with opaque content, e.g., video streaming widgets, it is better to set the widget's Qt::WA_OpaquePaintEvent, avoiding any unnecessary overhead associated with repainting the widget's background.

If a widget has both the Qt::WA_OpaquePaintEvent widget attribute and the autoFillBackground property set, the Qt::WA_OpaquePaintEvent attribute takes precedence. Depending on your requirements, you should choose either one of them.

Since Qt 4.1, the contents of parent widgets are also propagated to standard Qt widgets. This can lead to some unexpected results if the parent widget is decorated in a non-standard way, as shown in the diagram below.

propagation-standard.png

The scope for customizing the painting behavior of standard Qt widgets, without resorting to subclassing, is slightly less than that possible for custom widgets. Usually, the desired appearance of a standard widget can be achieved by setting its autoFillBackground property.

Creating Translucent Windows

Since Qt 4.5, it has been possible to create windows with translucent regions on window systems that support compositing.

To enable this feature in a top-level widget, set its Qt::WA_TranslucentBackground attribute with setAttribute() and ensure that its background is painted with non-opaque colors in the regions you want to be partially transparent.

Platform notes:

Native Widgets vs Alien Widgets

Introduced in Qt 4.4, alien widgets are widgets unknown to the windowing system. They do not have a native window handle associated with them. This feature significantly speeds up widget painting, resizing, and removes flicker.

Should you require the old behavior with native windows, you can choose one of the following options:

  1. Use the QT_USE_NATIVE_WINDOWS=1 in your environment.
  2. Set the Qt::AA_NativeWindows attribute on your application. All widgets will be native widgets.
  3. Set the Qt::WA_NativeWindow attribute on widgets: The widget itself and all of its ancestors will become native (unless Qt::WA_DontCreateNativeAncestors is set).
  4. Call QWidget::winId to enforce a native window (this implies 3).
  5. Set the Qt::WA_PaintOnScreen attribute to enforce a native window (this implies 3).
See also
QEvent, QPainter, QGridLayout, QBoxLayout

Softkeys

Since Qt 4.6, Softkeys are usually physical keys on a device that have a corresponding label or other visual representation on the screen that is generally located next to its physical counterpart. They are most often found on mobile phone platforms. In modern touch based user interfaces it is also possible to have softkeys that do not correspond to any physical keys. Softkeys differ from other onscreen labels in that they are contextual.

In Qt, contextual softkeys are added to a widget by calling addAction() and passing a QAction with a softkey role set on it. When the widget containing the softkey actions has focus, its softkeys should appear in the user interface. Softkeys are discovered by traversing the widget hierarchy so it is possible to define a single set of softkeys that are present at all times by calling addAction() for a given top level widget.

On some platforms, this concept overlaps with QMenuBar such that if no other softkeys are found and the top level widget is a QMainWindow containing a QMenuBar, the menubar actions may appear on one of the softkeys.

Note: Currently softkeys are only supported on the Symbian Platform.

See also
addAction(), QAction, QMenuBar

Definition at line 150 of file qwidget.h.

Enumerations

◆ RenderFlag

This enum describes how to render the widget when calling QWidget::render().

  • DrawWindowBackground If you enable this option, the widget's background is rendered into the target even if autoFillBackground is not set. By default, this option is enabled.
  • DrawChildren If you enable this option, the widget's children are rendered recursively into the target. By default, this option is enabled.
  • IgnoreMask If you enable this option, the widget's QWidget::mask() is ignored when rendering into the target. By default, this option is disabled.
Since
4.3
Enumerator
DrawWindowBackground 
DrawChildren 
IgnoreMask 

Definition at line 227 of file qwidget.h.

Constructors and Destructors

◆ QWidget() [1/2]

QWidget::QWidget ( QWidget parent = 0,
Qt::WindowFlags  f = 0 
)
explicit

Constructs a widget which is a child of parent, with widget flags set to f.

If parent is 0, the new widget becomes a 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 widget flags argument, f, is normally 0, but it can be set to customize the frame of a window (i.e. parent must be 0). To customize the frame, use a value composed from the bitwise OR of any of the window flags.

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.

See also
windowFlags

Definition at line 1189 of file qwidget.cpp.

Referenced by QPrintPropertiesDialog::addItemToOptions(), QColumnViewPrivate::createColumn(), QScriptEdit::extraAreaMouseEvent(), focusPreviousChild(), QMainWindowLayout::getSeparatorWidget(), QAbstractScrollAreaPrivate::init(), QGroupBox::mouseReleaseEvent(), QComboBox::QComboBox(), QDialog::QDialog(), QFrame::QFrame(), QLineEdit::QLineEdit(), QMainWindow::QMainWindow(), QMenuBar::QMenuBar(), QPrintPropertiesDialog::QPrintPropertiesDialog(), QSizeGrip::QSizeGrip(), QTabWidget::QTabWidget(), QToolBar::QToolBar(), QWorkspace::QWorkspace(), QX11EmbedContainer::QX11EmbedContainer(), QWizardPrivate::recreateLayout(), QAbstractButton::setIconSize(), QWorkspace::setScrollBarsEnabled(), QTabBarPrivate::setupMovableTab(), QAbstractScrollArea::setViewport(), QSystemTrayIconSys::sysTrayTracker(), QMenuBarPrivate::updateCornerWidgetToolBar(), xdndEnable(), and xdndObtainData().

1190  : QObject(*new QWidgetPrivate, 0), QPaintDevice()
1191 {
1192  QT_TRY {
1193  d_func()->init(parent, f);
1194  } QT_CATCH(...) {
1195  QWidgetExceptionCleaner::cleanup(this, d_func());
1196  QT_RETHROW;
1197  }
1198 }
#define QT_RETHROW
Definition: qglobal.h:1539
#define QT_CATCH(A)
Definition: qglobal.h:1537
static void cleanup(QWidget *that, QWidgetPrivate *d)
Definition: qwidget.cpp:1147
Q_INVOKABLE QObject(QObject *parent=0)
Constructs an object with parent object parent.
Definition: qobject.cpp:753
#define QT_TRY
Definition: qglobal.h:1536

◆ ~QWidget()

QWidget::~QWidget ( )

Destroys the widget.

All this widget's children are deleted first. The application exits if this widget is the main widget.

Definition at line 1572 of file qwidget.cpp.

1573 {
1574  Q_D(QWidget);
1575  d->data.in_destructor = true;
1576 
1577 #if defined (QT_CHECK_STATE)
1578  if (paintingActive())
1579  qWarning("QWidget: %s (%s) deleted while being painted", className(), name());
1580 #endif
1581 
1582 #ifndef QT_NO_GESTURES
1583  foreach (Qt::GestureType type, d->gestureContext.keys())
1584  ungrabGesture(type);
1585 #endif
1586 
1587  // force acceptDrops false before winId is destroyed.
1588  d->registerDropSite(false);
1589 
1590 #ifndef QT_NO_ACTION
1591  // remove all actions from this widget
1592  for (int i = 0; i < d->actions.size(); ++i) {
1593  QActionPrivate *apriv = d->actions.at(i)->d_func();
1594  apriv->widgets.removeAll(this);
1595  }
1596  d->actions.clear();
1597 #endif
1598 
1599 #ifndef QT_NO_SHORTCUT
1600  // Remove all shortcuts grabbed by this
1601  // widget, unless application is closing
1603  qApp->d_func()->shortcutMap.removeShortcut(0, this, QKeySequence());
1604 #endif
1605 
1606  // delete layout while we still are a valid widget
1607  delete d->layout;
1608  d->layout = 0;
1609  // Remove myself from focus list
1610 
1611  Q_ASSERT(d->focus_next->d_func()->focus_prev == this);
1612  Q_ASSERT(d->focus_prev->d_func()->focus_next == this);
1613 
1614  if (d->focus_next != this) {
1615  d->focus_next->d_func()->focus_prev = d->focus_prev;
1616  d->focus_prev->d_func()->focus_next = d->focus_next;
1617  d->focus_next = d->focus_prev = 0;
1618  }
1619 
1620 #ifdef QT3_SUPPORT
1621  if (QApplicationPrivate::main_widget == this) { // reset main widget
1624  }
1625 #endif
1626 
1627  QT_TRY {
1628  clearFocus();
1629  } QT_CATCH(...) {
1630  // swallow this problem because we are in a destructor
1631  }
1632 
1633  d->setDirtyOpaqueRegion();
1634 
1635  if (isWindow() && isVisible() && internalWinId()) {
1636  QT_TRY {
1637  d->close_helper(QWidgetPrivate::CloseNoEvent);
1638  } QT_CATCH(...) {
1639  // if we're out of memory, at least hide the window.
1640  QT_TRY {
1641  hide();
1642  } QT_CATCH(...) {
1643  // and if that also doesn't work, then give up
1644  }
1645  }
1646  }
1647 
1648 #if defined(Q_WS_WIN) || defined(Q_WS_X11)|| defined(Q_WS_MAC)
1649  else if (!internalWinId() && isVisible()) {
1650  qApp->d_func()->sendSyntheticEnterLeave(this);
1651  }
1652 #elif defined(Q_WS_QWS) || defined(Q_WS_QPA)
1653  else if (isVisible()) {
1654  qApp->d_func()->sendSyntheticEnterLeave(this);
1655  }
1656 #endif
1657 
1658 #ifdef Q_OS_SYMBIAN
1659  if (d->extra && d->extra->topextra && d->extra->topextra->backingStore) {
1660  // Okay, we are about to destroy the top-level window that owns
1661  // the backing store. Make sure we delete the backing store right away
1662  // before the window handle is invalid. This is important because
1663  // the backing store will delete its window surface, which may or may
1664  // not have a reference to this widget that will be used later to
1665  // notify the window it no longer has a surface.
1666  d->extra->topextra->backingStore.destroy();
1667  }
1668 #endif
1669  if (QWidgetBackingStore *bs = d->maybeBackingStore()) {
1670  bs->removeDirtyWidget(this);
1672  bs->removeStaticWidget(this);
1673  }
1674 
1675  delete d->needsFlush;
1676  d->needsFlush = 0;
1677 
1678  // set all QPointers for this object to zero
1679  if (d->hasGuards)
1681 
1682  if (d->declarativeData) {
1683  QAbstractDeclarativeData::destroyed(d->declarativeData, this);
1684  d->declarativeData = 0; // don't activate again in ~QObject
1685  }
1686 
1687 #ifdef QT_MAC_USE_COCOA
1688  // QCocoaView holds a pointer back to this widget. Clear it now
1689  // to make sure it's not followed later on. The lifetime of the
1690  // QCocoaView might exceed the lifetime of this widget in cases
1691  // where Cocoa itself holds references to it.
1692  extern void qt_mac_clearCocoaViewQWidgetPointers(QWidget *);
1693  qt_mac_clearCocoaViewQWidgetPointers(this);
1694 #endif
1695 
1696  if (!d->children.isEmpty())
1697  d->deleteChildren();
1698 
1699 #ifndef QT_NO_ACCESSIBILITY
1701 #endif
1702 
1704 
1705  QT_TRY {
1706  destroy(); // platform-dependent cleanup
1707  } QT_CATCH(...) {
1708  // if this fails we can't do anything about it but at least we are not allowed to throw.
1709  }
1711 
1712  if (QWidgetPrivate::allWidgets) // might have been deleted by ~QApplication
1714 
1715  QT_TRY {
1717  QCoreApplication::sendEvent(this, &e);
1718  } QT_CATCH(const std::exception&) {
1719  // if this fails we can't do anything about it but at least we are not allowed to throw.
1720  }
1721 }
static void clearGuards(QObject *)
Definition: qobject.cpp:467
double d
Definition: qnumeric_p.h:62
static QWidget * main_widget
static void updateAccessibility(QObject *, int who, Event reason)
Notifies accessibility clients about a change in object&#39;s accessibility information.
int type
Definition: qmetatype.cpp:239
bool isWindow() const
Returns true if the widget is an independent window, otherwise returns false.
Definition: qwidget.h:945
bool isVisible() const
Definition: qwidget.h:1005
bool remove(const T &value)
Definition: qset.h:89
QList< QWidget * > widgets
Definition: qaction_p.h:121
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define Q_D(Class)
Definition: qglobal.h:2482
const char * className
Definition: qwizard.cpp:137
bool paintingActive() const
Definition: qpaintdevice.h:170
void clearFocus()
Takes keyboard input focus from the widget.
Definition: qwidget.cpp:6757
static void quit()
Tells the application to exit with return code 0 (success).
void destroy(bool destroyWindow=true, bool destroySubWindows=true)
Frees up window system resources.
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
#define qApp
const char * name
Q_CORE_EXPORT void qWarning(const char *,...)
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
#define QT_CATCH(A)
Definition: qglobal.h:1537
static QWidgetSet * allWidgets
Definition: qwidget_p.h:715
GestureType
Definition: qnamespace.h:1759
void hide()
Hides the widget.
Definition: qwidget.h:501
The QKeySequence class encapsulates a key sequence as used by shortcuts.
Definition: qkeysequence.h:72
static void(* destroyed)(QAbstractDeclarativeData *, QObject *)
Definition: qobject_p.h:93
WId internalWinId() const
Returns the window system identifier of the widget, or 0 if the widget is not created yet...
Definition: qwidget.h:244
removePostedEvents
Removes all events of the given eventType that were posted using postEvent() for receiver.
void ungrabGesture(Qt::GestureType type)
Unsubscribes the widget from a given gesture type.
Definition: qwidget.cpp:12977
static int instanceCounter
Definition: qwidget_p.h:752
The QEvent class is the base class of all event classes.
Definition: qcoreevent.h:56
#define QT_TRY
Definition: qglobal.h:1536
int removeAll(const T &t)
Removes all occurrences of value in the list and returns the number of entries removed.
Definition: qlist.h:770

◆ QWidget() [2/2]

QWidget::QWidget ( QWidgetPrivate dd,
QWidget parent,
Qt::WindowFlags  f 
)
protected
Warning
This function is not part of the public interface.

Definition at line 1220 of file qwidget.cpp.

1221  : QObject(dd, 0), QPaintDevice()
1222 {
1223  Q_D(QWidget);
1224  QT_TRY {
1225  d->init(parent, f);
1226  } QT_CATCH(...) {
1227  QWidgetExceptionCleaner::cleanup(this, d_func());
1228  QT_RETHROW;
1229  }
1230 }
double d
Definition: qnumeric_p.h:62
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_D(Class)
Definition: qglobal.h:2482
#define QT_RETHROW
Definition: qglobal.h:1539
#define QT_CATCH(A)
Definition: qglobal.h:1537
static void cleanup(QWidget *that, QWidgetPrivate *d)
Definition: qwidget.cpp:1147
Q_INVOKABLE QObject(QObject *parent=0)
Constructs an object with parent object parent.
Definition: qobject.cpp:753
#define QT_TRY
Definition: qglobal.h:1536

Functions

◆ acceptDrops()

bool QWidget::acceptDrops ( ) const

◆ accessibleDescription()

QString QWidget::accessibleDescription ( ) const

◆ accessibleName()

QString QWidget::accessibleName ( ) const

◆ actionEvent()

void QWidget::actionEvent ( QActionEvent event)
protectedvirtual

This event handler is called with the given event whenever the widget's actions are changed.

See also
addAction(), insertAction(), removeAction(), actions(), QActionEvent

Reimplemented in QMenu, QToolBar, QTornOffMenu, QMenuBar, and QToolButton.

Definition at line 9600 of file qwidget.cpp.

Referenced by QToolButton::actionEvent(), event(), QToolBar::isAreaAllowed(), and setShown().

9601 {
9602 
9603 }

◆ actions()

QList< QAction * > QWidget::actions ( ) const

Returns the (possibly empty) list of this widget's actions.

See also
contextMenuPolicy, insertAction(), removeAction()

Definition at line 3407 of file qwidget.cpp.

Referenced by QMenuBarPrivate::_q_actionHovered(), QMenuBarPrivate::_q_internalShortcutActivated(), QWorkspacePrivate::_q_operationMenuActivated(), QWorkspacePrivate::_q_updateActions(), QMenuBarPrivate::actionAt(), QMenuBarPrivate::actionRect(), QAccessibleMenu::actionText(), QAccessibleWidget::actionText(), QAccessibleMenuBar::actionText(), actualMenuItemVisibility(), QSoftKeyManager::appendSoftkeys(), QMenuBarPrivate::calcActionRects(), QAccessibleMenu::childAt(), QAccessibleMenu::childCount(), QAccessibleMenuBar::childCount(), QMenuBar::clear(), QToolBar::clear(), QMenu::clear(), QAxServerBase::createMenu(), QAxServerBase::createPopup(), QMenuBar::defaultAction(), QAccessibleMenu::doAction(), QAccessibleMenuBar::doAction(), QMenuBarPrivate::focusFirstAction(), QMenuBarPrivate::getNextAction(), QMenuPrivate::hideMenu(), QAccessibleMenu::indexOfChild(), QAccessibleMenuBar::indexOfChild(), QWorkspacePrivate::init(), QMenu::isEmpty(), QUnicodeControlCharacterMenu::menuActionTriggered(), QAxClientSite::OnPosRectChange(), QToolButtonPrivate::popupTimerDone(), qt_wce_get_quit_action(), QTornOffMenu::QTornOffMenu(), QMenuBarPrivate::QWceMenuBarPrivate::rebuild(), QFileDialog::restoreState(), QAccessibleMenu::role(), QAccessibleMenuBar::role(), QToolButton::setDefaultAction(), QAbstractItemView::setEditTriggers(), QMenuBar::setNativeMenuBar(), QMenu::setSeparatorsCollapsible(), QSidebar::showContextMenu(), QAccessibleMenu::state(), QAccessibleMenuBar::state(), QAccessibleMenu::text(), QMenuBarPrivate::updateGeometries(), and QAccessibleWidget::userActionCount().

3408 {
3409  Q_D(const QWidget);
3410  return d->actions;
3411 }
double d
Definition: qnumeric_p.h:62
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_D(Class)
Definition: qglobal.h:2482

◆ activateWindow()

void QWidget::activateWindow ( )

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 activateWindow() 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 change the color of the taskbar entry to indicate that the window has changed in some way. This is because Microsoft does not allow an application to interrupt what the user is currently doing in another application.

See also
isActiveWindow(), window(), show()

Definition at line 3363 of file qwidget_mac.mm.

Referenced by QMessageBox::about(), QMessageBox::aboutQt(), QAccessibleWidget::doAction(), QAccessibleApplication::doAction(), QApplicationPrivate::globalEventProcessor(), QWorkspacePrivate::hideChild(), isServerProcess(), QWorkspacePrivate::maximizeWindow(), QWorkspacePrivate::minimizeWindow(), QWorkspacePrivate::normalizeWindow(), qstring_to_xtp(), qt_cleanup(), qt_grab_cursor(), qt_try_modal(), QtWndProc(), QApplication::qwsProcessEvent(), QBBWindow::setVisible(), showFullScreen(), QScriptDebuggerPrivate::startInteraction(), QETWidget::translateMouseEvent(), QSystemTrayIconSys::winEvent(), QApplication::x11ClientMessage(), and QWorkspaceChild::~QWorkspaceChild().

3364 {
3365  QWidget *tlw = window();
3366  if(!tlw->isVisible() || !tlw->isWindow() || (tlw->windowType() == Qt::Desktop))
3367  return;
3369 
3370  QWidget *fullScreenWidget = tlw;
3371  QWidget *parentW = tlw;
3372  // Find the oldest parent or the parent with fullscreen, whichever comes first.
3373  while (parentW) {
3374  fullScreenWidget = parentW->window();
3375  if (fullScreenWidget->windowState() & Qt::WindowFullScreen)
3376  break;
3377  parentW = fullScreenWidget->parentWidget();
3378  }
3379 
3380  if (fullScreenWidget->windowType() != Qt::ToolTip) {
3382  qApp->desktop()->screenNumber(this) == 0);
3383  }
3384 
3385  bool windowActive;
3386  OSWindowRef win = qt_mac_window_for(tlw);
3387 #ifndef QT_MAC_USE_COCOA
3388  windowActive = IsWindowActive(win);
3389 #else
3391  windowActive = [win isKeyWindow];
3392 #endif
3393  if ((tlw->windowType() == Qt::Popup)
3394  || (tlw->windowType() == Qt::Tool)
3395  || qt_mac_is_macdrawer(tlw)
3396  || windowActive) {
3397 #ifndef QT_MAC_USE_COCOA
3398  ActivateWindow(win, true);
3399  qApp->setActiveWindow(tlw);
3400 #else
3401  [win makeKeyWindow];
3402 #endif
3403  } else if(!isMinimized()) {
3404 #ifndef QT_MAC_USE_COCOA
3405  SelectWindow(win);
3406 #else
3407  [win makeKeyAndOrderFront:win];
3408 #endif
3409  }
3410 }
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
static void qt_mac_set_fullscreen_mode(bool b)
Definition: qwidget_mac.mm:406
Qt::WindowStates windowState() const
Returns the current window state.
Definition: qwidget.cpp:3086
bool isWindow() const
Returns true if the widget is an independent window, otherwise returns false.
Definition: qwidget.h:945
bool isVisible() const
Definition: qwidget.h:1005
bool qt_event_remove_activate()
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
friend OSWindowRef qt_mac_window_for(const QWidget *w)
Definition: qwidget_mac.mm:484
WindowRef OSWindowRef
#define qApp
bool qt_mac_is_macdrawer(const QWidget *w)
Definition: qwidget_mac.mm:306
bool isMinimized() const
Definition: qwidget.cpp:3027
QWidget * window() const
Returns the window for this widget, i.e.
Definition: qwidget.cpp:4492
Qt::WindowType windowType() const
Returns the window type of this widget.
Definition: qwidget.h:937

◆ addAction()

void QWidget::addAction ( QAction action)

Appends the action action to this widget's list of actions.

All QWidgets have a list of QAction, however they can be represented graphically in many different ways. The default use of the QAction list (as returned by actions()) is to create a context QMenu.

A QWidget should only have one of each action and adding an action it already has will not cause the same action to be in the widget twice.

The ownership of action is not transferred to this QWidget.

See also
removeAction(), insertAction(), actions(), QMenu

Definition at line 3317 of file qwidget.cpp.

Referenced by QDialogButtonBoxPrivate::addButton(), QFileDialogPrivate::createWidgets(), QDialogButtonBox::event(), QMenuBarPrivate::handleReparent(), QToolBar::isAreaAllowed(), QAbstractItemView::keyPressEvent(), QErrorMessage::QErrorMessage(), QProgressDialog::setCancelButton(), QToolButton::setDefaultAction(), QComboBoxPrivateContainer::setItemView(), QPushButton::setMenu(), and QToolButton::setMenu().

3318 {
3319  insertAction(0, action);
3320 }
void insertAction(QAction *before, QAction *action)
Inserts the action action to this widget&#39;s list of actions, before the action before.
Definition: qwidget.cpp:3342

◆ addActions()

void QWidget::addActions ( QList< QAction *>  actions)

Appends the actions actions to this widget's list of actions.

See also
removeAction(), QMenu, addAction()

Definition at line 3327 of file qwidget.cpp.

Referenced by QMenu::exec(), QMdiSubWindow::QMdiSubWindow(), and QMenuBarPrivate::updateGeometries().

3328 {
3329  for(int i = 0; i < actions.count(); i++)
3330  insertAction(0, actions.at(i));
3331 }
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
void insertAction(QAction *before, QAction *action)
Inserts the action action to this widget&#39;s list of actions, before the action before.
Definition: qwidget.cpp:3342

◆ adjustSize()

void QWidget::adjustSize ( )

Adjusts the size of the widget to fit its contents.

This function uses sizeHint() if it is valid, i.e., the size hint's width and height are >= 0. Otherwise, it sets the size to the children rectangle that covers all child widgets (the union of all child widget rectangles).

For windows, the screen size is also taken into account. If the sizeHint() is less than (200, 100) and the size policy is expanding, the window will be at least (200, 100). The maximum size of a window is 2/3 of the screen's width and height.

See also
sizeHint(), childrenRect()

Definition at line 8488 of file qwidget.cpp.

Referenced by QWorkspace::addWindow(), QComboBox::setEditable(), setVisible(), and QGraphicsProxyWidgetPrivate::setWidget_helper().

8489 {
8490  Q_D(QWidget);
8491  ensurePolished();
8492  QSize s = d->adjustedSize();
8493 
8494  if (d->layout)
8495  d->layout->activate();
8496 
8497  if (s.isValid())
8498  resize(s);
8499 }
double d
Definition: qnumeric_p.h:62
void ensurePolished() const
Ensures that the widget has been polished by QStyle (i.e., has a proper font and palette).
Definition: qwidget.cpp:10024
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_D(Class)
Definition: qglobal.h:2482
void resize(int w, int h)
This corresponds to resize(QSize(w, h)).
Definition: qwidget.h:1014
bool isValid() const
Returns true if both the width and height is equal to or greater than 0; otherwise returns false...
Definition: qsize.h:123
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53

◆ autoFillBackground()

bool QWidget::autoFillBackground ( ) const

Referenced by resetInputContext().

◆ backgroundRole()

QPalette::ColorRole QWidget::backgroundRole ( ) const

Returns the background role of the widget.

The background role defines the brush from the widget's palette that is used to render the background.

If no explicit background role is set, the widget inherts its parent widget's background role.

See also
setBackgroundRole(), foregroundRole()

Definition at line 4677 of file qwidget.cpp.

Referenced by QRenderRule::configurePalette(), QEgl::createSurface(), QPlastiqueStyle::drawComplexControl(), QCleanlooksStyle::drawComplexControl(), QGtkStyle::drawComplexControl(), QPlastiqueStyle::drawControl(), QCleanlooksStyle::drawControl(), QPlastiqueStyle::drawPrimitive(), QStyleSheetStyle::drawPrimitive(), foregroundRole(), QPainter::initFrom(), QAxClientSite::Invoke(), nativeParentWidget(), QGraphicsView::paintEvent(), QGLOverlayWidget::paintGL(), qt_plastique_draw_handle(), qt_plastique_drawFrame(), QDirectFBWindowSurface::updateIsOpaque(), and QToolBoxPrivate::updateTabs().

4678 {
4679 
4680  const QWidget *w = this;
4681  do {
4682  QPalette::ColorRole role = w->d_func()->bg_role;
4683  if (role != QPalette::NoRole)
4684  return role;
4685  if (w->isWindow() || w->windowType() == Qt::SubWindow)
4686  break;
4687  w = w->parentWidget();
4688  } while (w);
4689  return QPalette::Window;
4690 }
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
ColorRole
The ColorRole enum defines the different symbolic color roles used in current GUIs.
Definition: qpalette.h:93
bool isWindow() const
Returns true if the widget is an independent window, otherwise returns false.
Definition: qwidget.h:945
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
Qt::WindowType windowType() const
Returns the window type of this widget.
Definition: qwidget.h:937

◆ baseSize()

QSize QWidget::baseSize ( ) const

◆ changeEvent()

void QWidget::changeEvent ( QEvent event)
protectedvirtual

This event handler can be reimplemented to handle state changes.

The state being changed in this event can be retrieved through the event supplied.

Change events include: QEvent::ToolBarChange, QEvent::ActivationChange, QEvent::EnabledChange, QEvent::FontChange, QEvent::StyleChange, QEvent::PaletteChange, QEvent::WindowTitleChange, QEvent::IconTextChange, QEvent::ModifiedChange, QEvent::MouseTrackingChange, QEvent::ParentChange, QEvent::WindowStateChange, QEvent::LanguageChange, QEvent::LocaleChange, QEvent::LayoutDirectionChange.

Reimplemented in QWorkspaceChild, QMessageBox, QTextEdit, QFileDialog, QPlainTextEdit, QComboBox, QComboBoxPrivateContainer, QLineEdit, QTabBar, QTabWidget, QMenu, QAbstractSlider, QDialogButtonBox, QAbstractSpinBox, QToolBar, QAbstractButton, QLabel, QMenuBar, QFrame, QProgressDialog, QColorDialog, QSplitter, QToolButton, QFontDialog, QDockWidget, QMdiSubWindow, QToolBox, QWorkspace, QGroupBox, QAxWidget, QRubberBand, QExpandingLineEdit, QErrorMessage, and QWSEmbedWidget.

Definition at line 9170 of file qwidget.cpp.

Referenced by QComboBox::addItems(), QErrorMessage::changeEvent(), QRubberBand::changeEvent(), QGroupBox::changeEvent(), QWorkspace::changeEvent(), QDockWidget::changeEvent(), QFontDialog::changeEvent(), QMdiSubWindow::changeEvent(), QColorDialog::changeEvent(), QProgressDialog::changeEvent(), QFrame::changeEvent(), QMenuBar::changeEvent(), QAbstractButton::changeEvent(), QAbstractSpinBox::changeEvent(), QToolBar::changeEvent(), QDialogButtonBox::changeEvent(), QAbstractSlider::changeEvent(), QMenu::changeEvent(), QTabWidget::changeEvent(), QTabBar::changeEvent(), QLineEdit::changeEvent(), QComboBoxPrivateContainer::changeEvent(), QComboBox::changeEvent(), QFileDialog::changeEvent(), QMessageBox::changeEvent(), QWorkspaceChild::changeEvent(), QMessageBox::critical(), event(), QToolBar::isAreaAllowed(), QDockWidget::isAreaAllowed(), QRubberBand::resize(), and setShown().

9171 {
9172  switch(event->type()) {
9173  case QEvent::EnabledChange:
9174  update();
9175 #ifndef QT_NO_ACCESSIBILITY
9177 #endif
9178  break;
9179 
9180  case QEvent::FontChange:
9181  case QEvent::StyleChange: {
9182  Q_D(QWidget);
9183  update();
9184  updateGeometry();
9185  if (d->layout)
9186  d->layout->invalidate();
9187 #ifdef Q_WS_QWS
9188  if (isWindow())
9189  d->data.fstrut_dirty = true;
9190 #endif
9191  break;
9192  }
9193 
9194  case QEvent::PaletteChange:
9195  update();
9196  break;
9197 
9198 #ifdef Q_WS_MAC
9199  case QEvent::MacSizeChange:
9200  updateGeometry();
9201  break;
9202  case QEvent::ToolTipChange:
9205  break;
9206 #endif
9207 
9208  default:
9209  break;
9210  }
9211 }
double d
Definition: qnumeric_p.h:62
static void updateAccessibility(QObject *, int who, Event reason)
Notifies accessibility clients about a change in object&#39;s accessibility information.
bool isWindow() const
Returns true if the widget is an independent window, otherwise returns false.
Definition: qwidget.h:945
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
void qt_mac_update_mouseTracking(QWidget *widget)
#define Q_D(Class)
Definition: qglobal.h:2482
void update()
Updates the widget unless updates are disabled or the widget is hidden.
Definition: qwidget.cpp:10883
void updateGeometry()
Notifies the layout system that this widget has changed and may need to change geometry.
Definition: qwidget.cpp:10372
Type type() const
Returns the event type.
Definition: qcoreevent.h:303

◆ childAt() [1/2]

QWidget * QWidget::childAt ( int  x,
int  y 
) const
inline

Returns the visible child widget at the position ({x}, {y}) in the widget's coordinate system.

If there is no visible child widget at the specified position, the function returns 0.

Definition at line 934 of file qwidget.h.

Referenced by QToolBar::actionAt(), QDialog::contextMenuEvent(), QMainWindow::contextMenuEvent(), QGestureManager::deliverEvents(), QOleDropTarget::DragOver(), QOleDropTarget::Drop(), effectiveState(), QToolBar::event(), flipPoint(), QApplicationPrivate::globalEventProcessor(), QX11Data::motifdndHandle(), parseGeometry(), qt_cleanup(), qt_tabletMotion_scanner(), qt_try_modal(), QtWndProc(), QApplication::qwsProcessEvent(), QGraphicsProxyWidgetPrivate::sendWidgetMouseEvent(), QETWidget::translateMouseEvent(), QApplicationPrivate::translateRawTouchEvent(), QETWidget::translateXinputEvent(), QApplication::widgetAt(), and QApplication::x11ProcessEvent().

935 { return childAt(QPoint(ax, ay)); }
QWidget * childAt(int x, int y) const
Returns the visible child widget at the position ({x}, {y}) in the widget&#39;s coordinate system...
Definition: qwidget.h:934
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53

◆ childAt() [2/2]

QWidget * QWidget::childAt ( const QPoint p) const

Returns the visible child widget at point p in the widget's own coordinate system.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 10283 of file qwidget.cpp.

10284 {
10285  return d_func()->childAt_helper(p, false);
10286 }

◆ childrenRect()

QRect QWidget::childrenRect ( ) const

Referenced by setDisabled().

◆ childrenRegion()

QRegion QWidget::childrenRegion ( ) const

Referenced by setDisabled().

◆ clearFocus()

void QWidget::clearFocus ( )

Takes keyboard input focus from the widget.

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.

This widget must enable focus setting in order to get the keyboard input focus, i.e. it must call setFocusPolicy().

See also
hasFocus(), setFocus(), focusInEvent(), focusOutEvent(), setFocusPolicy(), QApplication::focusWidget()

Definition at line 6757 of file qwidget.cpp.

Referenced by QtWndProc(), QMdiSubWindowPrivate::setActive(), setAttribute(), QStackedLayout::setCurrentIndex(), setParent(), and ~QWidget().

6758 {
6759  QWidget *w = this;
6760  while (w) {
6761  if (w->d_func()->focus_child == this)
6762  w->d_func()->focus_child = 0;
6763  w = w->parentWidget();
6764  }
6765 #ifndef QT_NO_GRAPHICSVIEW
6766  QWExtra *topData = d_func()->extra;
6767  if (topData && topData->proxyWidget)
6768  topData->proxyWidget->clearFocus();
6769 #endif
6770 
6771  if (hasFocus()) {
6772  // Update proxy state
6774 #if defined(Q_WS_WIN)
6775  if (!(windowType() == Qt::Popup) && GetFocus() == internalWinId())
6776  SetFocus(0);
6777  else
6778 #endif
6779  {
6780 #ifndef QT_NO_ACCESSIBILITY
6782 #endif
6783  }
6784  }
6785 }
static void updateAccessibility(QObject *, int who, Event reason)
Notifies accessibility clients about a change in object&#39;s accessibility information.
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
void clearFocus()
Takes keyboard input focus from the item.
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
bool hasFocus() const
Definition: qwidget.cpp:6583
QGraphicsProxyWidget * proxyWidget
Definition: qwidget_p.h:251
static void setFocusWidget(QWidget *focus, Qt::FocusReason reason)
WId internalWinId() const
Returns the window system identifier of the widget, or 0 if the widget is not created yet...
Definition: qwidget.h:244
Qt::WindowType windowType() const
Returns the window type of this widget.
Definition: qwidget.h:937

◆ clearMask()

void QWidget::clearMask ( )

Removes any mask set by setMask().

See also
setMask()

Definition at line 13324 of file qwidget.cpp.

Referenced by QShapedPixmapWidget::setPixmap(), QWorkspaceChild::updateMask(), and QApplication::widgetAt().

13325 {
13326  setMask(QRegion());
13327 }
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
void setMask(const QBitmap &)
Causes only the pixels of the widget for which bitmap has a corresponding 1 bit to be visible...
Definition: qwidget.cpp:13309

◆ close

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. If it ignores the event, nothing happens. The default implementation of QWidget::closeEvent() accepts the close event.

If the widget has the Qt::WA_DeleteOnClose flag, the widget is also deleted. A close events is delivered to the widget no matter if the widget is visible or not.

The QApplication::lastWindowClosed() signal is emitted when the last visible primary window (i.e. window with no parent) with the Qt::WA_QuitOnClose attribute set is closed. By default this attribute is set for all widgets except transient windows such as splash screens, tool windows, and popup menus.

Definition at line 8305 of file qwidget.cpp.

Referenced by QMdiAreaPrivate::_q_closeTab(), QWorkspaceChild::childEvent(), QMdiArea::closeAllSubWindows(), QWorkspace::closeAllWindows(), QApplication::closeAllWindows(), QApplication::commitData(), QCalendarPopup::dateSelected(), event(), QMdiSubWindow::eventFilter(), QSplashScreen::finish(), QApplicationPrivate::globalEventProcessor(), QMenuPrivate::hideMenu(), QTipLabel::hideTipImmediately(), QWorkspaceChild::iconWidget(), QMenu::keyPressEvent(), QWhatsThat::keyPressEvent(), keyPressEvent(), QMdiSubWindow::mouseDoubleClickEvent(), QBalloonTip::mousePressEvent(), QWhatsThat::mousePressEvent(), QMdiAreaTabBar::mousePressEvent(), mousePressEvent(), QWhatsThat::mouseReleaseEvent(), onApplicationChangedActivation(), QBalloonTip::QBalloonTip(), QmlApplicationViewer::QmlApplicationViewer(), QtWndProc(), QWorkspaceChild::QWorkspaceChild(), QApplication::qwsProcessEvent(), QDecoration::regionClicked(), QProgressDialog::setAutoClose(), QWellArray::setSelected(), QWidgetPrivate::show_helper(), QBalloonTip::timerEvent(), QETWidget::translateMouseEvent(), QETWidget::translateWheelEvent(), update(), and QApplication::x11ProcessEvent().

8306 {
8307  return d_func()->close_helper(QWidgetPrivate::CloseWithEvent);
8308 }

◆ closeEvent()

void QWidget::closeEvent ( QCloseEvent event)
protectedvirtual

This event handler is called with the given event when Qt receives a window close request for a top-level widget from the window system.

By default, the event is accepted and the widget is closed. You can reimplement this function to change the way the widget responds to window close requests. For example, you can prevent the window from closing by calling QEvent::ignore() on all events.

Main window applications typically use reimplementations of this function to check whether the user's work has been saved and ask for permission before closing. For example, the Application Example uses a helper function to determine whether or not to close the window:

void MainWindow::closeEvent(QCloseEvent *event)
{
if (maybeSave()) {
writeSettings();
event->accept();
} else {
event->ignore();
}
}
See also
event(), hide(), close(), QCloseEvent, {Application Example}

Reimplemented in QRollEffect, QMessageBox, QAbstractSpinBox, QProgressDialog, QDockWidget, QMdiSubWindow, QDialog, and QAlphaWidget.

Definition at line 9626 of file qwidget.cpp.

Referenced by QAlphaWidget::closeEvent(), QDockWidget::closeEvent(), QAbstractSpinBox::closeEvent(), QRollEffect::closeEvent(), event(), QDockWidget::isAreaAllowed(), and setShown().

9627 {
9628  event->accept();
9629 }

◆ contentsMargins()

QMargins QWidget::contentsMargins ( ) const

The contentsMargins function returns the widget's contents margins.

Since
4.6
See also
getContentsMargins(), setContentsMargins(), contentsRect()

Definition at line 7532 of file qwidget.cpp.

7533 {
7534  Q_D(const QWidget);
7535  return QMargins(d->leftmargin, d->topmargin, d->rightmargin, d->bottommargin);
7536 }
double d
Definition: qnumeric_p.h:62
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_D(Class)
Definition: qglobal.h:2482
The QMargins class defines the four margins of a rectangle.
Definition: qmargins.h:53

◆ contentsRect()

QRect QWidget::contentsRect ( ) const

Returns the area inside the widget's margins.

See also
setContentsMargins(), getContentsMargins()

Definition at line 7544 of file qwidget.cpp.

Referenced by QGroupBoxPrivate::calculateFrame(), QSplitterHandle::closestLegalPosition(), QColorPicker::colPt(), QWorkspaceChild::frameWidth(), QColorPicker::huePt(), QLineEdit::initStyleOption(), QColorPicker::mouseMoveEvent(), QSizeGrip::mousePressEvent(), QColorPicker::mousePressEvent(), QLabel::paintEvent(), QSplitterHandle::paintEvent(), QPlainTextEdit::paintEvent(), QColorPicker::paintEvent(), QColorShowLabel::paintEvent(), QWorkspaceChild::QWorkspaceChild(), QAccessibleMdiSubWindow::rect(), QScriptEdit::resizeEvent(), QSplitterHandle::resizeEvent(), QWorkspaceChild::resizeEvent(), QColorPicker::satPt(), QLineEdit::selectionStart(), QColorPicker::setCol(), QMdiSubWindowPrivate::setMaximizeMode(), QSplitter::setRubberBand(), QLabel::setScaledContents(), QTabWidget::setUpLayout(), QMdiSubWindow::showSystemMenu(), QAccessibleMdiSubWindow::state(), and QFramePrivate::updateFrameWidth().

7545 {
7546  Q_D(const QWidget);
7547  return QRect(QPoint(d->leftmargin, d->topmargin),
7548  QPoint(data->crect.width() - 1 - d->rightmargin,
7549  data->crect.height() - 1 - d->bottommargin));
7550 
7551 }
double d
Definition: qnumeric_p.h:62
QRect crect
Definition: qwidget.h:131
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
#define Q_D(Class)
Definition: qglobal.h:2482
QWidgetData * data
Definition: qwidget.h:815
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58

◆ contextMenuEvent()

void QWidget::contextMenuEvent ( QContextMenuEvent event)
protectedvirtual

This event handler, for event event, can be reimplemented in a subclass to receive widget context menu events.

The handler is called when the widget's contextMenuPolicy is Qt::DefaultContextMenu.

The default implementation ignores the context event. See the QContextMenuEvent documentation for more details.

See also
event(), QContextMenuEvent customContextMenuRequested()

Reimplemented in QMdiAreaTabBar, QTextEdit, QWorkspaceTitleBar, QComboBox, QGraphicsView, QPlainTextEdit, QLineEdit, QMainWindow, QLabel, QAbstractSpinBox, QMdiSubWindow, QDialog, QAbstractScrollArea, QMessageBoxDetailsText::TextEdit, QScrollBar, and QmlJSDebugger::ToolBarColorBox.

Definition at line 9645 of file qwidget.cpp.

Referenced by QComboBox::addItems(), QScrollBar::contextMenuEvent(), QToolBar::event(), event(), and setShown().

9646 {
9647  event->ignore();
9648 }

◆ contextMenuPolicy()

Qt::ContextMenuPolicy QWidget::contextMenuPolicy ( ) const

◆ create()

void QWidget::create ( WId  window = 0,
bool  initializeWindow = true,
bool  destroyOldWindow = true 
)
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).

The QWidget constructor calls create(0,true,true) to create a window for this widget.

Definition at line 1454 of file qwidget.cpp.

Referenced by QSystemTrayIconSys::addToTray(), QWidgetPrivate::createWinId(), lower(), QGLOverlayWidget::paintGL(), QMacNativeWidget::QMacNativeWidget(), qt_set_winid_on_widget(), raise(), QMacCocoaViewContainer::setCocoaView(), setParent(), setVisible(), and stackUnder().

1455 {
1456  Q_D(QWidget);
1458  return;
1459 
1460  if (d->data.in_destructor)
1461  return;
1462 
1464  Qt::WindowFlags &flags = data->window_flags;
1465 
1466  if ((type == Qt::Widget || type == Qt::SubWindow) && !parentWidget()) {
1467  type = Qt::Window;
1468  flags |= Qt::Window;
1469  }
1470 
1471 #ifndef Q_WS_QPA
1472  if (QWidget *parent = parentWidget()) {
1473  if (type & Qt::Window) {
1474  if (!parent->testAttribute(Qt::WA_WState_Created))
1475  parent->createWinId();
1476  } else if (testAttribute(Qt::WA_NativeWindow) && !parent->internalWinId()
1478  // We're about to create a native child widget that doesn't have a native parent;
1479  // enforce a native handle for the parent unless the Qt::WA_DontCreateNativeAncestors
1480  // attribute is set.
1481  d->createWinId(window);
1482  // Nothing more to do.
1485  return;
1486  }
1487  }
1488 #endif //Q_WS_QPA
1489 
1490 #ifdef QT3_SUPPORT
1491  if (flags & Qt::WStaticContents)
1493  if (flags & Qt::WDestructiveClose)
1495  if (flags & Qt::WShowModal)
1497  if (flags & Qt::WMouseNoMask)
1499  if (flags & Qt::WGroupLeader)
1501  if (flags & Qt::WNoMousePropagation)
1503 #endif
1504 
1505  static int paintOnScreenEnv = -1;
1506  if (paintOnScreenEnv == -1)
1507  paintOnScreenEnv = qgetenv("QT_ONSCREEN_PAINT").toInt() > 0 ? 1 : 0;
1508  if (paintOnScreenEnv == 1)
1510 
1513 
1514 #ifdef ALIEN_DEBUG
1515  qDebug() << "QWidget::create:" << this << "parent:" << parentWidget()
1516  << "Alien?" << !testAttribute(Qt::WA_NativeWindow);
1517 #endif
1518 
1519 #if defined (Q_WS_WIN) && !defined(QT_NO_DRAGANDDROP)
1520  // Unregister the dropsite (if already registered) before we
1521  // re-create the widget with a native window.
1523  && d->extra && d->extra->dropTarget) {
1524  d->registerDropSite(false);
1525  }
1526 #endif // defined (Q_WS_WIN) && !defined(QT_NO_DRAGANDDROP)
1527 
1528  d->updateIsOpaque();
1529 
1530  setAttribute(Qt::WA_WState_Created); // set created flag
1531  d->create_sys(window, initializeWindow, destroyOldWindow);
1532 
1533  // a real toplevel window needs a backing store
1534  if (isWindow() && windowType() != Qt::Desktop) {
1535  d->topData()->backingStore.destroy();
1536  if (hasBackingStoreSupport())
1537  d->topData()->backingStore.create(this);
1538  }
1539 
1540  d->setModal_sys();
1541 
1544 
1545 #ifdef QT_EVAL
1546  extern void qt_eval_init_widget(QWidget *w);
1547  qt_eval_init_widget(this);
1548 #endif
1549 
1550  // need to force the resting of the icon after changing parents
1552  d->setWindowIcon_sys(true);
1553  if (isWindow() && !d->topData()->iconText.isEmpty())
1554  d->setWindowIconText_helper(d->topData()->iconText);
1555  if (isWindow() && !d->topData()->caption.isEmpty())
1556  d->setWindowTitle_helper(d->topData()->caption);
1557  if (windowType() != Qt::Desktop) {
1558  d->updateSystemBackground();
1559 
1561  d->setWindowIcon_sys();
1562  }
1563 }
double d
Definition: qnumeric_p.h:62
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
Q_CORE_EXPORT QByteArray qgetenv(const char *varName)
int type
Definition: qmetatype.cpp:239
static bool hasBackingStoreSupport()
Definition: qwidget.cpp:169
bool isWindow() const
Returns true if the widget is an independent window, otherwise returns false.
Definition: qwidget.h:945
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
static bool testAttribute(uint flag)
WindowType
Definition: qnamespace.h:270
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define Q_D(Class)
Definition: qglobal.h:2482
Q_CORE_EXPORT void qDebug(const char *,...)
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
Qt::WindowFlags window_flags
Definition: qwidget.h:119
QWidgetData * data
Definition: qwidget.h:815
void setWindowModality(Qt::WindowModality windowModality)
Definition: qwidget.cpp:2991
int toInt(bool *ok=0, int base=10) const
Returns the byte array converted to an int using base base, which is 10 by default and must be betwee...
QObject * parent() const
Returns a pointer to the parent object.
Definition: qobject.h:273
WId internalWinId() const
Returns the window system identifier of the widget, or 0 if the widget is not created yet...
Definition: qwidget.h:244
void setAttribute(Qt::WidgetAttribute, bool on=true)
Sets the attribute attribute on this widget if on is true; otherwise clears the attribute.
Definition: qwidget.cpp:11087
QWidget * window() const
Returns the window for this widget, i.e.
Definition: qwidget.cpp:4492
Qt::WindowType windowType() const
Returns the window type of this widget.
Definition: qwidget.h:937

◆ createWinId()

void QWidget::createWinId ( )
Warning
This function is not part of the public interface. Ensures that the widget has a window system identifier, i.e. that it is known to the windowing system.

Definition at line 2626 of file qwidget.cpp.

Referenced by QMainWindow::addDockWidget(), create(), QWidgetPrivate::create_sys(), QMenu::exec(), QClipboardWatcher::getDataInFormat(), QToolBarPrivate::init(), QPageSetupDialogPrivate::openCarbonPageLayout(), QPrintDialogPrivate::openCarbonPrintPanel(), QRubberBand::QRubberBand(), qt_nograb(), qt_tablet_init(), qt_tablet_init_wce(), qt_win_get_existing_directory(), QX11EmbedContainer::QX11EmbedContainer(), QX11EmbedWidget::QX11EmbedWidget(), QDockAreaLayoutInfo::restoreState(), QMainWindow::setUnifiedTitleAndToolBarOnMac(), setupOwner(), and winId().

2627 {
2628  Q_D(QWidget);
2629 #ifdef ALIEN_DEBUG
2630  qDebug() << "QWidget::createWinId" << this;
2631 #endif
2632 // qWarning("QWidget::createWinId is obsolete, please fix your code.");
2633  d->createWinId();
2634 }
double d
Definition: qnumeric_p.h:62
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_D(Class)
Definition: qglobal.h:2482
Q_CORE_EXPORT void qDebug(const char *,...)

◆ cursor()

QCursor QWidget::cursor ( ) const

◆ customContextMenuRequested

void QWidget::customContextMenuRequested ( const QPoint pos)
signal

This signal is emitted when the widget's contextMenuPolicy is Qt::CustomContextMenu, and the user has requested a context menu on the widget.

The position pos is the position of the context menu event that the widget receives. Normally this is in widget coordinates. The exception to this rule is QAbstractScrollArea and its subclasses that map the context menu event to coordinates of the viewport() .

See also
mapToGlobal() QMenu contextMenuPolicy

Referenced by event(), QSidebar::init(), and setShown().

◆ destroy()

void QWidget::destroy ( bool  destroyWindow = true,
bool  destroySubWindows = true 
)
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.

Definition at line 2751 of file qwidget_mac.mm.

Referenced by QWidgetPrivate::isBackgroundInherited(), isServerProcess(), q_createNativeChildrenAndSetParent(), QMacCocoaViewContainer::setCocoaView(), setShown(), QApplication::~QApplication(), and ~QWidget().

2752 {
2753  Q_D(QWidget);
2755  d->aboutToDestroy();
2756  if (!isWindow() && parentWidget())
2757  parentWidget()->d_func()->invalidateBuffer(d->effectiveRectFor(geometry()));
2758  if (!internalWinId())
2760  d->deactivateWidgetCleanup();
2761  qt_mac_event_release(this);
2764  QObjectList chldrn = children();
2765  for(int i = 0; i < chldrn.size(); i++) { // destroy all widget children
2766  QObject *obj = chldrn.at(i);
2767  if(obj->isWidgetType())
2768  static_cast<QWidget*>(obj)->destroy(destroySubWindows, destroySubWindows);
2769  }
2770  if(mac_mouse_grabber == this)
2771  releaseMouse();
2772  if(mac_keyboard_grabber == this)
2773  releaseKeyboard();
2774 
2775  if(testAttribute(Qt::WA_ShowModal)) // just be sure we leave modal
2777  else if((windowType() == Qt::Popup))
2778  qApp->d_func()->closePopup(this);
2779  if (destroyWindow) {
2780  if(OSViewRef hiview = qt_mac_nativeview_for(this)) {
2781  OSWindowRef window = 0;
2782  NSDrawer *drawer = nil;
2783 #ifdef QT_MAC_USE_COCOA
2784  if (qt_mac_is_macdrawer(this)) {
2785  drawer = qt_mac_drawer_for(this);
2786  } else
2787 #endif
2788  if (isWindow())
2789  window = qt_mac_window_for(hiview);
2790 
2791  // Because of how "destruct" works, we have to do just a normal release for the root_win.
2792  if (window && window == qt_root_win) {
2793 #ifndef QT_MAC_USE_COCOA
2794  CFRelease(hiview);
2795 #else
2796  [hiview release];
2797 #endif
2798  } else {
2799  qt_mac_destructView(hiview);
2800  }
2801  if (drawer)
2802  qt_mac_destructDrawer(drawer);
2803  if (window)
2804  qt_mac_destructWindow(window);
2805  }
2806 #ifdef QT_MAC_USE_COCOA
2807  if (isWindow())
2809 #endif
2810  }
2811  QT_TRY {
2812  d->setWinId(0);
2813  } QT_CATCH (const std::bad_alloc &) {
2814  // swallow - destructors must not throw
2815  }
2816  }
2817 }
double d
Definition: qnumeric_p.h:62
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
static void qt_mac_destructWindow(OSWindowRef window)
Definition: qwidget_mac.mm:253
QWidget * mac_mouse_grabber
Definition: qwidget_mac.mm:156
bool isWindow() const
Returns true if the widget is an independent window, otherwise returns false.
Definition: qwidget.h:945
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
friend OSWindowRef qt_mac_window_for(const QWidget *w)
Definition: qwidget_mac.mm:484
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
#define Q_D(Class)
Definition: qglobal.h:2482
QWidget * mac_keyboard_grabber
Definition: qwidget_mac.mm:157
void releaseMouse()
Releases the mouse grab.
WindowRef OSWindowRef
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
#define qApp
static void qt_mac_destructDrawer(NSDrawer *drawer)
Definition: qwidget_mac.mm:270
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
static void clearColorSpace(QWidget *w)
static OSWindowRef qt_root_win
Definition: qwidget_mac.mm:155
#define QT_CATCH(A)
Definition: qglobal.h:1537
void qt_mac_updateParentUnderAlienWidget(QWidget *alienWidget)
bool qt_mac_is_macdrawer(const QWidget *w)
Definition: qwidget_mac.mm:306
friend OSViewRef qt_mac_nativeview_for(const QWidget *w)
Definition: qwidget_mac.mm:419
bool isWidgetType() const
Returns true if the object is a widget; otherwise returns false.
Definition: qobject.h:146
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
const QObjectList & children() const
Returns a list of child objects.
Definition: qobject.h:197
void releaseKeyboard()
Releases the keyboard grab.
WId internalWinId() const
Returns the window system identifier of the widget, or 0 if the widget is not created yet...
Definition: qwidget.h:244
void setAttribute(Qt::WidgetAttribute, bool on=true)
Sets the attribute attribute on this widget if on is true; otherwise clears the attribute.
Definition: qwidget.cpp:11087
QWidget * window() const
Returns the window for this widget, i.e.
Definition: qwidget.cpp:4492
static void qt_mac_destructView(OSViewRef view)
Definition: qwidget_mac.mm:235
Qt::WindowType windowType() const
Returns the window type of this widget.
Definition: qwidget.h:937
HIViewRef OSViewRef
const QRect & geometry() const
static void leaveModal(QWidget *)
#define QT_TRY
Definition: qglobal.h:1536
void qt_mac_event_release(QWidget *w)

◆ devType()

int QWidget::devType ( ) const
virtual
Warning
This function is not part of the public interface.

Reimplemented from QPaintDevice.

Definition at line 1235 of file qwidget.cpp.

1236 {
1237  return QInternal::Widget;
1238 }

◆ dragEnterEvent()

void QWidget::dragEnterEvent ( QDragEnterEvent event)
protectedvirtual

This event handler is called when a drag is in progress and the mouse enters this widget.

The event is passed in the event parameter.

If the event is ignored, the widget won't receive any drag move events.

See the Drag-and-drop documentation for an overview of how to provide drag-and-drop in your application.

See also
QDrag, QDragEnterEvent

Reimplemented in QColorShowLabel, QColorWell, QAbstractItemView, QTextEdit, QGraphicsView, QPlainTextEdit, QLineEdit, QSidebar, and QAbstractScrollArea.

Definition at line 9768 of file qwidget.cpp.

Referenced by event(), QColorWell::QColorWell(), QColorShowLabel::setColor(), and setShown().

9769 {
9770 }

◆ dragLeaveEvent()

void QWidget::dragLeaveEvent ( QDragLeaveEvent event)
protectedvirtual

This event handler is called when a drag is in progress and the mouse leaves this widget.

The event is passed in the event parameter.

See the Drag-and-drop documentation for an overview of how to provide drag-and-drop in your application.

See also
QDrag, QDragLeaveEvent

Reimplemented in QColorShowLabel, QColorWell, QAbstractItemView, QTextEdit, QGraphicsView, QPlainTextEdit, QLineEdit, QListView, and QAbstractScrollArea.

Definition at line 9802 of file qwidget.cpp.

Referenced by event(), QColorWell::QColorWell(), QColorShowLabel::setColor(), and setShown().

9803 {
9804 }

◆ dragMoveEvent()

void QWidget::dragMoveEvent ( QDragMoveEvent event)
protectedvirtual

This event handler is called if a drag is in progress, and when any of the following conditions occur: the cursor enters this widget, the cursor moves within this widget, or a modifier key is pressed on the keyboard while this widget has the focus.

The event is passed in the event parameter.

See the Drag-and-drop documentation for an overview of how to provide drag-and-drop in your application.

See also
QDrag, QDragMoveEvent

Reimplemented in QColorWell, QAbstractItemView, QTextEdit, QGraphicsView, QPlainTextEdit, QLineEdit, QTreeView, QListView, and QAbstractScrollArea.

Definition at line 9786 of file qwidget.cpp.

Referenced by event(), QColorWell::QColorWell(), and setShown().

9787 {
9788 }

◆ dropEvent()

void QWidget::dropEvent ( QDropEvent event)
protectedvirtual

This event handler is called when the drag is dropped on this widget.

The event is passed in the event parameter.

See the Drag-and-drop documentation for an overview of how to provide drag-and-drop in your application.

See also
QDrag, QDropEvent

Reimplemented in QColorShowLabel, QColorWell, QTreeWidget, QAbstractItemView, QTableWidget, QTextEdit, QListWidget, QGraphicsView, QPlainTextEdit, QLineEdit, QListView, and QAbstractScrollArea.

Definition at line 9817 of file qwidget.cpp.

Referenced by event(), QColorWell::QColorWell(), QColorShowLabel::setColor(), and setShown().

9818 {
9819 }

◆ effectiveWinId()

WId QWidget::effectiveWinId ( ) const

Returns the effective window system identifier of the widget, i.

Since
4.4

e. the native parent's window system identifier.

If the widget is native, this function returns the native widget ID. Otherwise, the window ID of the first native parent widget, i.e., the top-level widget that contains this widget, is returned.

Note
We recommend that you do not store this value as it is likely to change at run-time.
See also
nativeParentWidget()

Definition at line 2654 of file qwidget.cpp.

Referenced by QApplicationPrivate::applyX11SpecificCommandLineArguments(), QWinInputContext::composition(), QXIMInputContext::createICData(), QApplicationPrivate::dispatchEnterLeave(), QWindowsVistaStyle::drawComplexControl(), QWinInputContext::enable(), enableIme(), QWinInputContext::endComposition(), QAxServerBase::eventFilter(), findParentforPopup(), findRealWindow(), getNetWmState(), handle_xdnd_position(), QXIMInputContext::isComposing(), QWinInputContext::mouseHandler(), qt_mac_checkForNativeSizeGrip(), qt_mac_desktopSize(), qt_mac_effectiveview_for(), qt_mac_insideKeyWindow(), qt_mac_unregister_widget(), qt_qpa_set_cursor(), qt_win_set_cursor(), qt_x11_enforce_cursor(), qt_xdnd_send_leave(), QtWndProc(), QWinInputContext::reset(), QXIMInputContext::reset(), QXIMInputContext::setFocusWidget(), QWinInputContext::startComposition(), QETWidget::translateMouseEvent(), QWinInputContext::update(), QXIMInputContext::update(), QXIMInputContext::widgetDestroyed(), QApplication::x11EventFilter(), QXIMInputContext::x11FilterEvent(), QApplication::x11ProcessEvent(), xdndEnable(), QX11Data::xdndHandleDrop(), and xdndObtainData().

2655 {
2656  WId id = internalWinId();
2658  return id;
2659  QWidget *realParent = nativeParentWidget();
2660  if (!realParent && d_func()->inSetParent) {
2661  // In transitional state. This is really just a workaround. The real problem
2662  // is that QWidgetPrivate::setParent_sys (platform specific code) first sets
2663  // the window id to 0 (setWinId(0)) before it sets the Qt::WA_WState_Created
2664  // attribute to false. The correct way is to do it the other way around, and
2665  // in that case the Qt::WA_WState_Created logic above will kick in and
2666  // return 0 whenever the widget is in a transitional state. However, changing
2667  // the original logic for all platforms is far more intrusive and might
2668  // break existing applications.
2669  // Note: The widget can only be in a transitional state when changing its
2670  // parent -- everything else is an internal error -- hence explicitly checking
2671  // against 'inSetParent' rather than doing an unconditional return whenever
2672  // 'realParent' is 0 (which may cause strange artifacts and headache later).
2673  return 0;
2674  }
2675  // This widget *must* have a native parent widget.
2676  Q_ASSERT(realParent);
2677  Q_ASSERT(realParent->internalWinId());
2678  return realParent->internalWinId();
2679 }
unsigned long WId
Definition: qwindowdefs.h:119
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
QWidget * nativeParentWidget() const
Returns the native parent for this widget, i.
Definition: qwidget.cpp:4514
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
WId internalWinId() const
Returns the window system identifier of the widget, or 0 if the widget is not created yet...
Definition: qwidget.h:244

◆ enabledChange()

void QWidget::enabledChange ( bool  )
protectedvirtual
Warning
This function is not part of the public interface.

Definition at line 12001 of file qwidget.cpp.

12001 { } // compat

◆ ensurePolished()

void QWidget::ensurePolished ( ) const

Ensures that the widget has been polished by QStyle (i.e., has a proper font and palette).

QWidget calls this function after it has been fully constructed but before it is shown the very first time. You can call this function if you want to ensure that the widget is polished before doing an operation, e.g., the correct font size might be needed in the widget's sizeHint() reimplementation. Note that this function is called from the default implementation of sizeHint().

Polishing is useful for final initialization that must happen after all constructors (from base classes as well as from subclasses) have been called.

If you need to change some settings when a widget is polished, reimplement event() and handle the QEvent::Polish event type.

Note: The function is declared const so that it can be called from other const functions (e.g., sizeHint()).

See also
event()

Definition at line 10024 of file qwidget.cpp.

Referenced by QWidgetPrivate::activateChildLayoutsRecursively(), adjustSize(), ensurePolished(), QMdiSubWindow::event(), event(), QMdiSubWindow::minimumSizeHint(), QSplitter::minimumSizeHint(), QMenuBar::minimumSizeHint(), QCalendarWidget::minimumSizeHint(), QLabel::minimumSizeHint(), QAbstractSpinBox::minimumSizeHint(), QLineEdit::minimumSizeHint(), QMenu::popup(), QTipLabel::QTipLabel(), QWhatsThat::QWhatsThat(), QHeaderView::sectionSizeFromContents(), setVisible(), QGraphicsProxyWidgetPrivate::setWidget_helper(), showFullScreen(), showMaximized(), showMinimized(), showNormal(), QRadioButton::sizeHint(), QScrollBar::sizeHint(), QCheckBox::sizeHint(), QPushButton::sizeHint(), QVistaBackButton::sizeHint(), QToolButton::sizeHint(), QSlider::sizeHint(), QProgressBar::sizeHint(), QSplitter::sizeHint(), QMDIControl::sizeHint(), QWellArray::sizeHint(), QMenuBar::sizeHint(), QDockWidgetTitleButton::sizeHint(), QAbstractSpinBox::sizeHint(), QLineEdit::sizeHint(), DetailButton::sizeHint(), QDateTimeEdit::sizeHint(), CloseButton::sizeHint(), QWorkspaceTitleBar::sizeHint(), QMdi::ControllerWidget::sizeHint(), QTableView::sizeHintForColumn(), QAbstractItemView::sizeHintForColumn(), QTreeView::sizeHintForColumn(), QTableView::sizeHintForRow(), QAbstractItemView::sizeHintForRow(), QSplitter::sizes(), QStyleSheetStyle::styleHint(), QLayout::totalHeightForWidth(), QLayout::totalMaximumSize(), QLayout::totalMinimumSize(), QLayout::totalSizeHint(), and QComboBoxPrivate::updateViewContainerPaletteAndOpacity().

10025 {
10026  Q_D(const QWidget);
10027 
10028  const QMetaObject *m = metaObject();
10029  if (m == d->polished)
10030  return;
10031  d->polished = m;
10032 
10034  QCoreApplication::sendEvent(const_cast<QWidget *>(this), &e);
10035 
10036  // polish children after 'this'
10037  QList<QObject*> children = d->children;
10038  for (int i = 0; i < children.size(); ++i) {
10039  QObject *o = children.at(i);
10040  if(!o->isWidgetType())
10041  continue;
10042  if (QWidget *w = qobject_cast<QWidget *>(o))
10043  w->ensurePolished();
10044  }
10045 
10046  if (d->parent && d->sendChildEvents) {
10047  QChildEvent e(QEvent::ChildPolished, const_cast<QWidget *>(this));
10048  QCoreApplication::sendEvent(d->parent, &e);
10049  }
10050 }
double d
Definition: qnumeric_p.h:62
The QMetaObject class contains meta-information about Qt objects.
Definition: qobjectdefs.h:304
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
#define Q_D(Class)
Definition: qglobal.h:2482
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
The QChildEvent class contains event parameters for child object events.
Definition: qcoreevent.h:353
bool isWidgetType() const
Returns true if the object is a widget; otherwise returns false.
Definition: qobject.h:146
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
const QObjectList & children() const
Returns a list of child objects.
Definition: qobject.h:197
The QEvent class is the base class of all event classes.
Definition: qcoreevent.h:56
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ enterEvent()

void QWidget::enterEvent ( QEvent event)
protectedvirtual

This event handler can be reimplemented in a subclass to receive widget enter events which are passed in the event parameter.

An event is sent to the widget when the mouse cursor enters the widget.

See also
leaveEvent(), mouseMoveEvent(), event()

Reimplemented in QWorkspaceChild, QWorkspaceTitleBar, CloseButton, QMenu, QComboBoxPrivateScroller, QDockWidgetTitleButton, QToolButton, and QVistaBackButton.

Definition at line 9475 of file qwidget.cpp.

Referenced by QVistaBackButton::enterEvent(), QToolButton::enterEvent(), QDockWidgetTitleButton::enterEvent(), CloseButton::enterEvent(), event(), and setShown().

9476 {
9477 }

◆ event()

bool QWidget::event ( QEvent event)
protectedvirtual

This is the main event handler; it handles event event.

You can reimplement this function in a subclass, but we recommend using one of the specialized event handlers instead.

Key press and release events are treated differently from other events. event() checks for Tab and Shift+Tab and tries to move the focus appropriately. If there is no widget to move the focus to (or the key press is not Tab or Shift+Tab), event() calls keyPressEvent().

Mouse and tablet event handling is also slightly special: only when the widget is enabled , event() will call the specialized handlers such as mousePressEvent(); otherwise it will discard the event.

This function returns true if the event was recognized, otherwise it returns false. If the recognized event was accepted (see QEvent::accepted ), any further processing such as event propagation to the parent widget stops.

See also
closeEvent(), focusInEvent(), focusOutEvent(), enterEvent(), keyPressEvent(), keyReleaseEvent(), leaveEvent(), mouseDoubleClickEvent(), mouseMoveEvent(), mousePressEvent(), mouseReleaseEvent(), moveEvent(), paintEvent(), resizeEvent(), QObject::event(), QObject::timerEvent()

Reimplemented from QObject.

Reimplemented in QMainWindowTabBar, QCalendarView, QGLWidget, QMdi::ControllerWidget, QMdi::ControlLabel, QTextEdit, QWorkspaceTitleBar, QLineEdit, QPlainTextEdit, QComboBox, QMainWindow, QTabBar, QMenu, QSplitterHandle, QSystemTrayIconSys, QCalendarPopup, QDateTimeEdit, QTabWidget, QDialogButtonBox, QCalendarWidget, QMdiArea, QToolBar, QMenuBar, QLabel, QAbstractSlider, QAbstractButton, QFrame, QAbstractSpinBox, QDockWidget, QX11EmbedContainer, QLCDNumber, QSplitter, QProgressBar, QMdiSubWindow, QToolButton, QTextBrowser, QSpinBox, QWorkspace, QStatusBar, QToolBox, QAbstractScrollArea, QSlider, QMDIControl, QFontComboBox, QGroupBox, QPushButton, QDial, QStackedWidget, QScriptDebuggerCodeView, QScriptEditExtraArea, QScrollArea, QSplashScreen, QRubberBand, QCheckBox, QX11EmbedWidget, QSizeGrip, QCommandLinkButton, QRadioButton, QScrollBar, QFocusFrame, and QMacNativeWidget.

Definition at line 8636 of file qwidget.cpp.

Referenced by QComboBox::addItems(), QSystemTrayIconSys::deliverToolTipEvent(), QX11Data::dndEnable(), QMacNativeWidget::event(), QFocusFrame::event(), QSizeGrip::event(), QX11EmbedWidget::event(), QRubberBand::event(), QSplashScreen::event(), QScriptEditExtraArea::event(), QGroupBox::event(), QMDIControl::event(), QStatusBar::event(), QWorkspace::event(), QDialog::event(), QMdiSubWindow::event(), QProgressBar::event(), QSplitter::event(), QX11EmbedContainer::event(), QDockWidget::event(), QAbstractSpinBox::event(), QFrame::event(), QAxHostWidget::event(), QAbstractButton::event(), QAbstractSlider::event(), QMenuBar::event(), QToolBar::event(), QCalendarWidget::event(), QDialogButtonBox::event(), QTabWidget::event(), QCalendarPopup::event(), QSystemTrayIconSys::event(), QSplitterHandle::event(), QMenu::event(), QTabBar::event(), QMainWindow::event(), QComboBox::event(), QLineEdit::event(), QWorkspaceTitleBar::event(), QMdi::ControlLabel::event(), QMdi::ControllerWidget::event(), QGLWidget::event(), QScriptBreakpointsItemDelegate::eventFilter(), QToolBar::isAreaAllowed(), QDockWidget::isAreaAllowed(), QCalendarWidget::isNavigationBarVisible(), qStoreColors(), qt_egl_create_surface(), QRubberBand::resize(), setCursor(), setFocus(), setToolTip(), QProgressBar::textDirection(), unsetCursor(), and x11EventFilter().

8637 {
8638  Q_D(QWidget);
8639 
8640  // ignore mouse events when disabled
8641  if (!isEnabled()) {
8642  switch(event->type()) {
8643  case QEvent::TabletPress:
8644  case QEvent::TabletRelease:
8645  case QEvent::TabletMove:
8649  case QEvent::MouseMove:
8650  case QEvent::TouchBegin:
8651  case QEvent::TouchUpdate:
8652  case QEvent::TouchEnd:
8653  case QEvent::ContextMenu:
8654 #ifndef QT_NO_WHEELEVENT
8655  case QEvent::Wheel:
8656 #endif
8657  return false;
8658  default:
8659  break;
8660  }
8661  }
8662  switch (event->type()) {
8663  case QEvent::MouseMove:
8664  mouseMoveEvent((QMouseEvent*)event);
8665  break;
8666 
8668  // Don't reset input context here. Whether reset or not is
8669  // a responsibility of input method. reset() will be
8670  // called by mouseHandler() of input method if necessary
8671  // via mousePressEvent() of text widgets.
8672 #if 0
8674 #endif
8675  mousePressEvent((QMouseEvent*)event);
8676  break;
8677 
8679  mouseReleaseEvent((QMouseEvent*)event);
8680  break;
8681 
8684  break;
8685 
8687  QWidget* w;
8688  while ((w = QApplication::activePopupWidget()) && w != this) {
8689  w->close();
8690  if (QApplication::activePopupWidget() == w) // widget does not want to disappear
8691  w->hide(); // hide at least
8692  }
8693  break;
8694  }
8695 
8696 #ifndef QT_NO_WHEELEVENT
8697  case QEvent::Wheel:
8698  wheelEvent((QWheelEvent*)event);
8699  break;
8700 #endif
8701 #ifndef QT_NO_TABLETEVENT
8702  case QEvent::TabletMove:
8703  case QEvent::TabletPress:
8704  case QEvent::TabletRelease:
8705  tabletEvent((QTabletEvent*)event);
8706  break;
8707 #endif
8708 #ifdef QT3_SUPPORT
8709  case QEvent::Accel:
8710  event->ignore();
8711  return false;
8712 #endif
8713  case QEvent::KeyPress: {
8714  QKeyEvent *k = (QKeyEvent *)event;
8715  bool res = false;
8716  if (!(k->modifiers() & (Qt::ControlModifier | Qt::AltModifier))) { //### Add MetaModifier?
8717  if (k->key() == Qt::Key_Backtab
8718  || (k->key() == Qt::Key_Tab && (k->modifiers() & Qt::ShiftModifier)))
8719  res = focusNextPrevChild(false);
8720  else if (k->key() == Qt::Key_Tab)
8721  res = focusNextPrevChild(true);
8722  if (res)
8723  break;
8724  }
8725  keyPressEvent(k);
8726 #ifdef QT_KEYPAD_NAVIGATION
8727  if (!k->isAccepted() && QApplication::keypadNavigationEnabled()
8729  if (QApplication::navigationMode() == Qt::NavigationModeKeypadTabOrder) {
8730  if (k->key() == Qt::Key_Up)
8731  res = focusNextPrevChild(false);
8732  else if (k->key() == Qt::Key_Down)
8733  res = focusNextPrevChild(true);
8734  } else if (QApplication::navigationMode() == Qt::NavigationModeKeypadDirectional) {
8735  if (k->key() == Qt::Key_Up)
8736  res = QWidgetPrivate::navigateToDirection(QWidgetPrivate::DirectionNorth);
8737  else if (k->key() == Qt::Key_Right)
8738  res = QWidgetPrivate::navigateToDirection(QWidgetPrivate::DirectionEast);
8739  else if (k->key() == Qt::Key_Down)
8740  res = QWidgetPrivate::navigateToDirection(QWidgetPrivate::DirectionSouth);
8741  else if (k->key() == Qt::Key_Left)
8742  res = QWidgetPrivate::navigateToDirection(QWidgetPrivate::DirectionWest);
8743  }
8744  if (res) {
8745  k->accept();
8746  break;
8747  }
8748  }
8749 #endif
8750 #ifndef QT_NO_WHATSTHIS
8751  if (!k->isAccepted()
8752  && k->modifiers() & Qt::ShiftModifier && k->key() == Qt::Key_F1
8753  && d->whatsThis.size()) {
8755  k->accept();
8756  }
8757 #endif
8758  }
8759  break;
8760 
8761  case QEvent::KeyRelease:
8762  keyReleaseEvent((QKeyEvent*)event);
8763  // fall through
8765  break;
8766 
8767  case QEvent::InputMethod:
8769  break;
8770 
8771  case QEvent::PolishRequest:
8772  ensurePolished();
8773  break;
8774 
8775  case QEvent::Polish: {
8776  style()->polish(this);
8778  if (!QApplication::font(this).isCopyOf(QApplication::font()))
8779  d->resolveFont();
8780  if (!QApplication::palette(this).isCopyOf(QApplication::palette()))
8781  d->resolvePalette();
8782 #ifdef QT3_SUPPORT
8783  if(d->sendChildEvents)
8784  QApplication::sendPostedEvents(this, QEvent::ChildInserted);
8785 #endif
8786  }
8787  break;
8788 
8791  d->setWindowIcon_sys();
8792  d->setWindowIcon_helper();
8793  }
8794  break;
8795  case QEvent::FocusIn:
8796 #ifdef QT_SOFTKEYS_ENABLED
8798 #endif
8799  focusInEvent((QFocusEvent*)event);
8800  break;
8801 
8802  case QEvent::FocusOut:
8803  focusOutEvent((QFocusEvent*)event);
8804  break;
8805 
8806  case QEvent::Enter:
8807 #ifndef QT_NO_STATUSTIP
8808  if (d->statusTip.size()) {
8809  QStatusTipEvent tip(d->statusTip);
8810  QApplication::sendEvent(const_cast<QWidget *>(this), &tip);
8811  }
8812 #endif
8813  enterEvent(event);
8814  break;
8815 
8816  case QEvent::Leave:
8817 #ifndef QT_NO_STATUSTIP
8818  if (d->statusTip.size()) {
8819  QString empty;
8820  QStatusTipEvent tip(empty);
8821  QApplication::sendEvent(const_cast<QWidget *>(this), &tip);
8822  }
8823 #endif
8824  leaveEvent(event);
8825  break;
8826 
8827  case QEvent::HoverEnter:
8828  case QEvent::HoverLeave:
8829  update();
8830  break;
8831 
8832  case QEvent::Paint:
8833  // At this point the event has to be delivered, regardless
8834  // whether the widget isVisible() or not because it
8835  // already went through the filters
8836  paintEvent((QPaintEvent*)event);
8837  break;
8838 
8839  case QEvent::Move:
8840  moveEvent((QMoveEvent*)event);
8841  break;
8842 
8843  case QEvent::Resize:
8844  resizeEvent((QResizeEvent*)event);
8845  break;
8846 
8847  case QEvent::Close:
8848  closeEvent((QCloseEvent *)event);
8849  break;
8850 
8851 #ifndef QT_NO_CONTEXTMENU
8852  case QEvent::ContextMenu:
8853  switch (data->context_menu_policy) {
8855  break;
8857  contextMenuEvent(static_cast<QContextMenuEvent *>(event));
8858  break;
8859  case Qt::CustomContextMenu:
8860  emit customContextMenuRequested(static_cast<QContextMenuEvent *>(event)->pos());
8861  break;
8862 #ifndef QT_NO_MENU
8864  if (d->actions.count()) {
8865  QMenu::exec(d->actions, static_cast<QContextMenuEvent *>(event)->globalPos(),
8866  0, this);
8867  break;
8868  }
8869  // fall through
8870 #endif
8871  default:
8872  event->ignore();
8873  break;
8874  }
8875  break;
8876 #endif // QT_NO_CONTEXTMENU
8877 
8878 #ifndef QT_NO_DRAGANDDROP
8879  case QEvent::Drop:
8880  dropEvent((QDropEvent*) event);
8881  break;
8882 
8883  case QEvent::DragEnter:
8884  dragEnterEvent((QDragEnterEvent*) event);
8885  break;
8886 
8887  case QEvent::DragMove:
8888  dragMoveEvent((QDragMoveEvent*) event);
8889  break;
8890 
8891  case QEvent::DragLeave:
8892  dragLeaveEvent((QDragLeaveEvent*) event);
8893  break;
8894 #endif
8895 
8896  case QEvent::Show:
8897  showEvent((QShowEvent*) event);
8898  break;
8899 
8900  case QEvent::Hide:
8901  hideEvent((QHideEvent*) event);
8902  break;
8903 
8905  if (!isHidden())
8906  d->show_sys();
8907  break;
8908 
8910  d->resolveFont();
8911  break;
8913  if (!(windowType() == Qt::Desktop))
8914  d->resolvePalette();
8915  break;
8916 
8917  case QEvent::ToolBarChange:
8919  case QEvent::EnabledChange:
8920  case QEvent::FontChange:
8921  case QEvent::StyleChange:
8922  case QEvent::PaletteChange:
8927  case QEvent::ParentChange:
8929  case QEvent::LocaleChange:
8930  case QEvent::MacSizeChange:
8932  changeEvent(event);
8933  break;
8934 
8936  case QEvent::WindowDeactivate: {
8937 #ifdef QT3_SUPPORT
8939 #endif
8941  update();
8942  QList<QObject*> childList = d->children;
8943  for (int i = 0; i < childList.size(); ++i) {
8944  QWidget *w = qobject_cast<QWidget *>(childList.at(i));
8945  if (w && w->isVisible() && !w->isWindow())
8946  QApplication::sendEvent(w, event);
8947  }
8948 
8949 #ifdef QT_SOFTKEYS_ENABLED
8950  if (isWindow())
8952 #endif
8953 
8954  break; }
8955 
8957 #ifdef QT3_SUPPORT
8958  languageChange();
8959 #endif
8960  changeEvent(event);
8961  {
8962  QList<QObject*> childList = d->children;
8963  for (int i = 0; i < childList.size(); ++i) {
8964  QObject *o = childList.at(i);
8965  if (o)
8966  QApplication::sendEvent(o, event);
8967  }
8968  }
8969  update();
8970  break;
8971 
8973  d->resolveLayoutDirection();
8974  break;
8975 
8977  if (d->layout)
8978  d->layout->invalidate();
8979  update();
8980  changeEvent(event);
8981  break;
8982  case QEvent::UpdateRequest:
8983  d->syncBackingStore();
8984  break;
8985  case QEvent::UpdateLater:
8986  update(static_cast<QUpdateLaterEvent*>(event)->region());
8987  break;
8988 
8989  case QEvent::WindowBlocked:
8991  {
8992  QList<QObject*> childList = d->children;
8993  for (int i = 0; i < childList.size(); ++i) {
8994  QObject *o = childList.at(i);
8995  if (o && o != QApplication::activeModalWidget()) {
8996  if (qobject_cast<QWidget *>(o) && static_cast<QWidget *>(o)->isWindow()) {
8997  // do not forward the event to child windows,
8998  // QApplication does this for us
8999  continue;
9000  }
9001  QApplication::sendEvent(o, event);
9002  }
9003  }
9004 #if defined(Q_WS_WIN)
9005  setDisabledStyle(this, (event->type() == QEvent::WindowBlocked));
9006 #endif
9007  }
9008  break;
9009 #ifndef QT_NO_TOOLTIP
9010  case QEvent::ToolTip:
9011  if (!d->toolTip.isEmpty())
9012  QToolTip::showText(static_cast<QHelpEvent*>(event)->globalPos(), d->toolTip, this);
9013  else
9014  event->ignore();
9015  break;
9016 #endif
9017 #ifndef QT_NO_WHATSTHIS
9018  case QEvent::WhatsThis:
9019  if (d->whatsThis.size())
9020  QWhatsThis::showText(static_cast<QHelpEvent *>(event)->globalPos(), d->whatsThis, this);
9021  else
9022  event->ignore();
9023  break;
9025  if (d->whatsThis.isEmpty())
9026  event->ignore();
9027  break;
9028 #endif
9029 #ifndef QT_NO_ACCESSIBILITY
9032  QAccessibleEvent *ev = static_cast<QAccessibleEvent *>(event);
9033  if (ev->child())
9034  return false;
9035  switch (ev->type()) {
9036 #ifndef QT_NO_TOOLTIP
9038  ev->setValue(d->toolTip);
9039  break;
9040 #endif
9041 #ifndef QT_NO_WHATSTHIS
9043  ev->setValue(d->whatsThis);
9044  break;
9045 #endif
9046  default:
9047  return false;
9048  }
9049  break; }
9050 #endif
9052  d->topData()->frameStrut.setCoords(0 ,0, 0, 0);
9053  data->fstrut_dirty = false;
9054 #if defined(Q_WS_WIN) || defined(Q_WS_X11)
9055  d->topData()->embedded = 1;
9056 #endif
9057  break;
9058 #ifndef QT_NO_ACTION
9059  case QEvent::ActionAdded:
9060  case QEvent::ActionRemoved:
9061  case QEvent::ActionChanged:
9062 #ifdef QT_SOFTKEYS_ENABLED
9064 #endif
9065  actionEvent((QActionEvent*)event);
9066  break;
9067 #endif
9068 
9070  {
9071  changeEvent(event);
9072 
9073  // inform children of the change
9074  QList<QObject*> childList = d->children;
9075  for (int i = 0; i < childList.size(); ++i) {
9076  QWidget *w = qobject_cast<QWidget *>(childList.at(i));
9077  if (w && w->isVisible() && !w->isWindow())
9078  QApplication::sendEvent(w, event);
9079  }
9080  break;
9081  }
9082 #ifdef Q_WS_MAC
9084  d->needWindowChange = false;
9085  break;
9086 #endif
9087  case QEvent::TouchBegin:
9088  case QEvent::TouchUpdate:
9089  case QEvent::TouchEnd:
9090  {
9091 #ifndef Q_WS_MAC
9092  QTouchEvent *touchEvent = static_cast<QTouchEvent *>(event);
9093  const QTouchEvent::TouchPoint &touchPoint = touchEvent->touchPoints().first();
9094  if (touchPoint.isPrimary() || touchEvent->deviceType() == QTouchEvent::TouchPad)
9095  break;
9096 
9097  // fake a mouse event!
9098  QEvent::Type eventType = QEvent::None;
9099  switch (touchEvent->type()) {
9100  case QEvent::TouchBegin:
9101  eventType = QEvent::MouseButtonPress;
9102  break;
9103  case QEvent::TouchUpdate:
9104  eventType = QEvent::MouseMove;
9105  break;
9106  case QEvent::TouchEnd:
9107  eventType = QEvent::MouseButtonRelease;
9108  break;
9109  default:
9110  Q_ASSERT(!true);
9111  break;
9112  }
9113  if (eventType == QEvent::None)
9114  break;
9115 
9116  QMouseEvent mouseEvent(eventType,
9117  touchPoint.pos().toPoint(),
9118  touchPoint.screenPos().toPoint(),
9121  touchEvent->modifiers());
9122  (void) QApplication::sendEvent(this, &mouseEvent);
9123 #endif // Q_WS_MAC
9124  break;
9125  }
9126 #ifndef QT_NO_GESTURES
9127  case QEvent::Gesture:
9128  event->ignore();
9129  break;
9130 #endif
9131 #ifndef QT_NO_PROPERTIES
9133  const QByteArray &propName = static_cast<QDynamicPropertyChangeEvent *>(event)->propertyName();
9134  if (!qstrncmp(propName, "_q_customDpi", 12) && propName.length() == 13) {
9135  uint value = property(propName.constData()).toUInt();
9136  if (!d->extra)
9137  d->createExtra();
9138  const char axis = propName.at(12);
9139  if (axis == 'X')
9140  d->extra->customDpiX = value;
9141  else if (axis == 'Y')
9142  d->extra->customDpiY = value;
9143  d->updateFont(d->data.fnt);
9144  }
9145  // fall through
9146  }
9147 #endif
9148  default:
9149  return QObject::event(event);
9150  }
9151  return true;
9152 }
QPoint pos() const
double d
Definition: qnumeric_p.h:62
The QKeyEvent class describes a key event.
Definition: qevent.h:224
virtual void showEvent(QShowEvent *)
This event handler can be reimplemented in a subclass to receive widget show events which are passed ...
Definition: qwidget.cpp:9842
virtual void inputMethodEvent(QInputMethodEvent *)
This event handler, for event event, can be reimplemented in a subclass to receive Input Method compo...
Definition: qwidget.cpp:9668
void resetInputContext()
This function can be called on the widget that currently has focus to reset the input method operatin...
Definition: qwidget.cpp:522
void ensurePolished() const
Ensures that the widget has been polished by QStyle (i.e., has a proper font and palette).
Definition: qwidget.cpp:10024
bool isWindow() const
Returns true if the widget is an independent window, otherwise returns false.
Definition: qwidget.h:945
The QWheelEvent class contains parameters that describe a wheel event.
Definition: qevent.h:139
bool isVisible() const
Definition: qwidget.h:1005
virtual void mouseReleaseEvent(QMouseEvent *)
This event handler, for event event, can be reimplemented in a subclass to receive mouse release even...
Definition: qwidget.cpp:9286
virtual void dragEnterEvent(QDragEnterEvent *)
This event handler is called when a drag is in progress and the mouse enters this widget...
Definition: qwidget.cpp:9768
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
virtual void mousePressEvent(QMouseEvent *)
This event handler, for event event, can be reimplemented in a subclass to receive mouse press events...
Definition: qwidget.cpp:9261
virtual void leaveEvent(QEvent *)
This event handler can be reimplemented in a subclass to receive widget leave events which are passed...
Definition: qwidget.cpp:9491
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
The QDynamicPropertyChangeEvent class contains event parameters for dynamic property change events...
Definition: qcoreevent.h:380
virtual void resizeEvent(QResizeEvent *)
This event handler can be reimplemented in a subclass to receive widget resize events which are passe...
Definition: qwidget.cpp:9587
virtual void moveEvent(QMoveEvent *)
This event handler can be reimplemented in a subclass to receive widget move events which are passed ...
Definition: qwidget.cpp:9566
virtual void keyReleaseEvent(QKeyEvent *)
This event handler, for event event, can be reimplemented in a subclass to receive key release events...
Definition: qwidget.cpp:9407
static QPalette palette()
Returns the application palette.
The QActionEvent class provides an event that is generated when a QAction is added, removed, or changed.
Definition: qevent.h:632
virtual QVariant inputMethodQuery(Qt::InputMethodQuery) const
This method is only relevant for input widgets.
Definition: qwidget.cpp:9683
The QString class provides a Unicode character string.
Definition: qstring.h:83
T * qobject_cast(QObject *object)
Definition: qobject.h:375
void customContextMenuRequested(const QPoint &pos)
This signal is emitted when the widget&#39;s contextMenuPolicy is Qt::CustomContextMenu, and the user has requested a context menu on the widget.
The QDragMoveEvent class provides an event which is sent while a drag and drop action is in progress...
Definition: qevent.h:530
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
virtual bool event(QEvent *)
This virtual function receives events to an object and should return true if the event e was recogniz...
Definition: qobject.cpp:1200
#define Q_D(Class)
Definition: qglobal.h:2482
virtual void focusOutEvent(QFocusEvent *)
This event handler can be reimplemented in a subclass to receive keyboard focus events (focus lost) f...
Definition: qwidget.cpp:9457
QStyle * style() const
Definition: qwidget.cpp:2742
static QFont font()
Returns the default application font.
virtual void languageChange()
Definition: qwidget.cpp:12005
bool isHidden() const
Returns true if the widget is hidden, otherwise returns false.
Definition: qwidget.h:1008
void update()
Updates the widget unless updates are disabled or the widget is hidden.
Definition: qwidget.cpp:10883
Qt::KeyboardModifiers modifiers() const
Returns the keyboard modifier flags that existed immediately after the event occurred.
Definition: qevent.cpp:999
virtual void paintEvent(QPaintEvent *)
This event handler can be reimplemented in a subclass to receive paint events passed in event...
Definition: qwidget.cpp:9548
int key() const
Returns the code of the key that was pressed or released.
Definition: qevent.h:231
static QWidget * activeModalWidget()
Returns the active modal widget.
void setDisabledStyle(QWidget *w, bool setStyle)
Definition: qwidget.cpp:8586
The QMoveEvent class contains event parameters for move events.
Definition: qevent.h:334
bool isAccepted() const
Definition: qcoreevent.h:307
The QAccessibleEvent class is used to query addition accessibility information about complex widgets...
Definition: qaccessible.h:449
QTouchEvent::DeviceType deviceType() const
Returns the touch device Type, which is of type QTouchEvent::DeviceType {DeviceType}.
Definition: qevent.h:818
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
#define emit
Definition: qobjectdefs.h:76
virtual void changeEvent(QEvent *)
This event handler can be reimplemented to handle state changes.
Definition: qwidget.cpp:9170
The QHideEvent class provides an event which is sent after a widget is hidden.
Definition: qevent.h:388
const QPalette & palette() const
virtual void mouseDoubleClickEvent(QMouseEvent *)
This event handler, for event event, can be reimplemented in a subclass to receive mouse double click...
Definition: qwidget.cpp:9306
QWidgetData * data
Definition: qwidget.h:815
The QResizeEvent class contains event parameters for resize events.
Definition: qevent.h:349
unsigned int uint
Definition: qglobal.h:996
virtual void actionEvent(QActionEvent *)
This event handler is called with the given event whenever the widget&#39;s actions are changed...
Definition: qwidget.cpp:9600
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
QPointF screenPos() const
Returns the screen position of this touch point.
Definition: qevent.cpp:4498
void setValue(const QString &aText)
Set the description or help text for the given child() to text, thereby answering the request...
Definition: qaccessible.h:455
static void sendPostedEvents()
The QDragLeaveEvent class provides an event that is sent to a widget when a drag and drop action leav...
Definition: qevent.h:577
The QShowEvent class provides an event that is sent when a widget is shown.
Definition: qevent.h:380
virtual void keyPressEvent(QKeyEvent *)
This event handler, for event event, can be reimplemented in a subclass to receive key press events f...
Definition: qwidget.cpp:9375
bool isEqual(ColorGroup cr1, ColorGroup cr2) const
Returns true (usually quickly) if color group cg1 is equal to cg2; otherwise returns false...
Definition: qpalette.cpp:1035
bool isEnabled() const
Definition: qwidget.h:948
The QTabletEvent class contains parameters that describe a Tablet event.
Definition: qevent.h:179
void hide()
Hides the widget.
Definition: qwidget.h:501
The QMouseEvent class contains parameters that describe a mouse event.
Definition: qevent.h:85
Q_CORE_EXPORT QTextStream & center(QTextStream &s)
int length() const
Same as size().
Definition: qbytearray.h:356
T & first()
Returns a reference to the first item in the list.
Definition: qlist.h:282
QAction * exec()
Executes this menu synchronously.
Definition: qmenu.cpp:2101
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
virtual void contextMenuEvent(QContextMenuEvent *)
This event handler, for event event, can be reimplemented in a subclass to receive widget context men...
Definition: qwidget.cpp:9645
The QInputMethodEvent class provides parameters for input method events.
Definition: qevent.h:431
virtual void tabletEvent(QTabletEvent *)
This event handler, for event event, can be reimplemented in a subclass to receive tablet events for ...
Definition: qwidget.cpp:9347
virtual void dragMoveEvent(QDragMoveEvent *)
This event handler is called if a drag is in progress, and when any of the following conditions occur...
Definition: qwidget.cpp:9786
static void updateSoftKeys()
The QDropEvent class provides an event which is sent when a drag and drop action is completed...
Definition: qevent.h:476
static QWidget * activePopupWidget()
Returns the active popup widget.
virtual void wheelEvent(QWheelEvent *)
This event handler, for event event, can be reimplemented in a subclass to receive wheel events for t...
Definition: qwidget.cpp:9326
Type
This enum type defines the valid event types in Qt.
Definition: qcoreevent.h:62
virtual void hideEvent(QHideEvent *)
This event handler can be reimplemented in a subclass to receive widget hide events.
Definition: qwidget.cpp:9864
virtual void dropEvent(QDropEvent *)
This event handler is called when the drag is dropped on this widget.
Definition: qwidget.cpp:9817
The QStatusTipEvent class provides an event that is used to show messages in a status bar...
Definition: qevent.h:606
QPoint toPoint() const
Rounds the coordinates of this point to the nearest integer, and returns a QPoint object with the rou...
Definition: qpoint.h:376
QPointF pos() const
Returns the position of this touch point, relative to the widget or QGraphicsItem that received the e...
Definition: qevent.cpp:4473
The QDragEnterEvent class provides an event which is sent to a widget when a drag and drop action ent...
Definition: qevent.h:555
virtual void closeEvent(QCloseEvent *)
This event handler is called with the given event when Qt receives a window close request for a top-l...
Definition: qwidget.cpp:9626
virtual bool focusNextPrevChild(bool next)
Finds a new widget to give the keyboard focus to, as appropriate for Tab and Shift+Tab, and returns true if it can find a new widget, or false if it can&#39;t.
Definition: qwidget.cpp:6836
const QList< QTouchEvent::TouchPoint > & touchPoints() const
Returns the list of touch points contained in the touch event.
Definition: qevent.h:820
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
int qstrncmp(const char *str1, const char *str2, uint len)
Definition: qbytearray.h:101
virtual void windowActivationChange(bool)
Definition: qwidget.cpp:12004
static void mouseEvent(MouseAction action, QWidget *widget, Qt::MouseButton button, Qt::KeyboardModifiers stateKey, QPoint pos, int delay=-1)
Definition: qtestmouse.h:71
void setAttribute(Qt::WidgetAttribute, bool on=true)
Sets the attribute attribute on this widget if on is true; otherwise clears the attribute.
Definition: qwidget.cpp:11087
bool isPrimary() const
Returns true if this touch point is the primary touch point.
Definition: qevent.cpp:4462
QVariant property(const char *name) const
Returns the value of the object&#39;s name property.
Definition: qobject.cpp:3807
The TouchPoint class provides information about a touch point in a QTouchEvent.
Definition: qevent.h:744
virtual void polish(QWidget *)
Initializes the appearance of the given widget.
Definition: qstyle.cpp:390
void ignore()
Clears the accept flag parameter of the event object, the equivalent of calling setAccepted(false).
Definition: qcoreevent.h:310
void accept()
Sets the accept flag of the event object, the equivalent of calling setAccepted(true).
Definition: qcoreevent.h:309
The QTouchEvent class contains parameters that describe a touch event.
Definition: qevent.h:741
Qt::WindowType windowType() const
Returns the window type of this widget.
Definition: qwidget.h:937
uint fstrut_dirty
Definition: qwidget.h:126
bool close()
Closes this widget.
Definition: qwidget.cpp:8305
bool event(QEvent *)
This is the main event handler; it handles event event.
Definition: qwidget.cpp:8636
QTouchEventSequence touchEvent(QWidget *widget=0, QTouchEvent::DeviceType deviceType=QTouchEvent::TouchScreen)
Creates and returns a QTouchEventSequence for the device deviceType to simulate events for widget...
Definition: qtesttouch.h:141
virtual void mouseMoveEvent(QMouseEvent *)
This event handler, for event event, can be reimplemented in a subclass to receive mouse move events ...
Definition: qwidget.cpp:9239
static void showText(const QPoint &pos, const QString &text, QWidget *w=0)
Shows text as a "What&#39;s This?" window, at global position pos.
Definition: qwhatsthis.cpp:754
virtual void dragLeaveEvent(QDragLeaveEvent *)
This event handler is called when a drag is in progress and the mouse leaves this widget...
Definition: qwidget.cpp:9802
char at(int i) const
Returns the character at index position i in the byte array.
Definition: qbytearray.h:413
Qt::KeyboardModifiers modifiers() const
Returns the keyboard modifier flags that existed immediately before the event occurred.
Definition: qevent.h:79
The QPaintEvent class contains event parameters for paint events.
Definition: qevent.h:298
Type type() const
Returns the event type.
Definition: qcoreevent.h:303
virtual void focusInEvent(QFocusEvent *)
This event handler can be reimplemented in a subclass to receive keyboard focus events (focus receive...
Definition: qwidget.cpp:9431
QPoint mapToGlobal(const QPoint &) const
Translates the widget coordinate pos to global screen coordinates.
The QCloseEvent class contains parameters that describe a close event.
Definition: qevent.h:364
The QFocusEvent class contains event parameters for widget focus events.
Definition: qevent.h:275
uint context_menu_policy
Definition: qwidget.h:127
virtual void enterEvent(QEvent *)
This event handler can be reimplemented in a subclass to receive widget enter events which are passed...
Definition: qwidget.cpp:9475
int child() const
Returns the (1-based) index of the child to which the request applies.
Definition: qaccessible.h:453
The QList class is a template class that provides lists.
Definition: qdatastream.h:62
static void showText(const QPoint &pos, const QString &text, QWidget *w=0)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qtooltip.cpp:497

◆ find()

QWidget * QWidget::find ( WId  id)
static

Returns a pointer to the widget with window identifer/handle id.

The window identifier type depends on the underlying window system, see qwindowdefs.h for the actual definition. If there is no widget with this identifier, 0 is returned.

Definition at line 2517 of file qwidget.cpp.

Referenced by axc_FilterProc(), QWinInputContext::enable(), QX11Data::findClientWindow(), findParentforPopup(), findRealWindow(), QGestureManager::getGestureTargets(), QApplicationPrivate::globalEventProcessor(), QXlibIntegration::grabWindow(), QVNCIntegration::grabWindow(), QPixmap::grabWindow(), handle_xdnd_position(), QBBScreenEventHandler::handleCloseEvent(), QXlibScreen::handleEvent(), QBBScreenEventHandler::handlePointerEvent(), QBBScreenEventHandler::handleTouchEvent(), QBBScreenEventHandler::injectPointerMoveEvent(), QKeyMapperPrivate::isADeadKey(), isServerProcess(), make_widget_eventUPP(), make_win_eventUPP(), QPlainTextEdit::maximumBlockCount(), parseGeometry(), platformWindowFromId(), QGuiEventDispatcherWin32::processEvents(), qax_winEventFilter(), qt_sync_request_scanner(), qt_win_getKeyboardModifiers(), qt_win_set_cursor(), qt_wince_full_screen(), qt_xdnd_send_leave(), QtWndProc(), qWinProcessConfigRequests(), QApplication::qwsProcessEvent(), QTextEdit::setUndoRedoEnabled(), QETWidget::translateMouseEvent(), QApplicationPrivate::translateTouchEvent(), QWinInputContext::update(), QApplication::x11EventFilter(), QApplication::x11ProcessEvent(), and xdndObtainData().

2518 {
2520 }
const T value(const Key &key) const
Returns the value associated with the key.
Definition: qhash.h:606
static QWidgetMapper * mapper
Definition: qwidget_p.h:714

◆ focusInEvent()

void QWidget::focusInEvent ( QFocusEvent event)
protectedvirtual

This event handler can be reimplemented in a subclass to receive keyboard focus events (focus received) for the widget.

The event is passed in the event parameter

A widget normally must setFocusPolicy() to something other than Qt::NoFocus in order to receive focus events. (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 windows that do not specify a focusPolicy()).

See also
focusOutEvent(), setFocusPolicy(), keyPressEvent(), keyReleaseEvent(), event(), QFocusEvent

Reimplemented in QAbstractItemView, QTextEdit, QGraphicsView, QPlainTextEdit, QComboBox, QLineEdit, QDateTimeEdit, QWellArray, QLabel, QAbstractSpinBox, QMenuBar, QAbstractButton, QSidebar, QMdiSubWindow, QAxHostWidget, QPushButton, and QGroupBox.

Definition at line 9431 of file qwidget.cpp.

Referenced by QComboBox::addItems(), event(), QGroupBox::focusInEvent(), QAxHostWidget::focusInEvent(), QSidebar::focusInEvent(), QAbstractButton::focusInEvent(), QAbstractSpinBox::focusInEvent(), QLabel::focusInEvent(), QPlainTextEdit::focusInEvent(), QGraphicsView::focusInEvent(), QTextEdit::focusInEvent(), QAbstractItemView::focusInEvent(), setShown(), and QPlainTextEdit::toPlainText().

9432 {
9433  if (focusPolicy() != Qt::NoFocus || !isWindow()) {
9434  update();
9435  }
9436 }
bool isWindow() const
Returns true if the widget is an independent window, otherwise returns false.
Definition: qwidget.h:945
Qt::FocusPolicy focusPolicy() const
void update()
Updates the widget unless updates are disabled or the widget is hidden.
Definition: qwidget.cpp:10883

◆ focusNextChild()

bool QWidget::focusNextChild ( )
inlineprotected

Finds a new widget to give the keyboard focus to, as appropriate for Tab, and returns true if it can find a new widget, or false if it can't.

See also
focusPreviousChild()

Definition at line 730 of file qwidget.h.

730 { return focusNextPrevChild(true); }
virtual bool focusNextPrevChild(bool next)
Finds a new widget to give the keyboard focus to, as appropriate for Tab and Shift+Tab, and returns true if it can find a new widget, or false if it can&#39;t.
Definition: qwidget.cpp:6836

◆ focusNextPrevChild()

bool QWidget::focusNextPrevChild ( bool  next)
protectedvirtual

Finds a new widget to give the keyboard focus to, as appropriate for Tab and Shift+Tab, and returns true if it can find a new widget, or false if it can't.

If next is true, this function searches forward, if next is false, it searches backward.

Sometimes, you will want to reimplement this function. For example, a web browser might reimplement it to move its "current active link" forward or backward, and call focusNextPrevChild() only when it reaches the last or first link on the "page".

Child widgets call focusNextPrevChild() on their parent widgets, but only the window that contains the child widgets decides where to redirect focus. By reimplementing this function for an object, you thus gain control of focus traversal for all child widgets.

See also
focusNextChild(), focusPreviousChild()

Reimplemented in QAbstractItemView, QTextEdit, QGraphicsView, QPlainTextEdit, QFocusHelper, QDateTimeEdit, QMenu, QLabel, QTextBrowser, QScriptDebuggerConsoleWidget, and QScrollArea.

Definition at line 6836 of file qwidget.cpp.

Referenced by QAxServerBase::ActiveXProc(), event(), focusNextChild(), QScrollArea::focusNextPrevChild(), QScriptDebuggerConsoleWidget::focusNextPrevChild(), QLabel::focusNextPrevChild(), QDateTimeEdit::focusNextPrevChild(), QFocusHelper::focusNextPrevChild(), QPlainTextEdit::focusNextPrevChild(), QGraphicsView::focusNextPrevChild(), QTextEdit::focusNextPrevChild(), QAbstractItemView::focusNextPrevChild(), focusNextPrevChild(), focusPreviousChild(), QAbstractButton::keyPressEvent(), setShown(), QPlainTextEdit::toPlainText(), QAxServerBase::TranslateAcceleratorW(), and QX11EmbedContainer::x11Event().

6837 {
6838  Q_D(QWidget);
6839  QWidget* p = parentWidget();
6840  bool isSubWindow = (windowType() == Qt::SubWindow);
6841  if (!isWindow() && !isSubWindow && p)
6842  return p->focusNextPrevChild(next);
6843 #ifndef QT_NO_GRAPHICSVIEW
6844  if (d->extra && d->extra->proxyWidget)
6845  return d->extra->proxyWidget->focusNextPrevChild(next);
6846 #endif
6848  if (!w) return false;
6849 
6851  return true;
6852 }
double d
Definition: qnumeric_p.h:62
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
bool isWindow() const
Returns true if the widget is an independent window, otherwise returns false.
Definition: qwidget.h:945
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_D(Class)
Definition: qglobal.h:2482
void setFocus()
Gives the keyboard input focus to this widget (or its focus proxy) if this widget or one of its paren...
Definition: qwidget.h:432
static QWidget * focusNextPrevChild_helper(QWidget *toplevel, bool next)
internal Helper function that returns the new focus widget, but does not set the focus reason...
virtual bool focusNextPrevChild(bool next)
Finds a new widget to give the keyboard focus to, as appropriate for Tab and Shift+Tab, and returns true if it can find a new widget, or false if it can&#39;t.
Definition: qwidget.cpp:6836
Qt::WindowType windowType() const
Returns the window type of this widget.
Definition: qwidget.h:937

◆ focusOutEvent()

void QWidget::focusOutEvent ( QFocusEvent event)
protectedvirtual

This event handler can be reimplemented in a subclass to receive keyboard focus events (focus lost) for the widget.

The events is passed in the event parameter.

A widget normally must setFocusPolicy() to something other than Qt::NoFocus in order to receive focus events. (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 windows that do not specify a focusPolicy()).

See also
focusInEvent(), setFocusPolicy(), keyPressEvent(), keyReleaseEvent(), event(), QFocusEvent

Reimplemented in QAbstractItemView, QTextEdit, QGraphicsView, QPlainTextEdit, QComboBox, QLineEdit, QWellArray, QLabel, QAbstractSpinBox, QAbstractButton, QMenuBar, QMdiSubWindow, QAxHostWidget, QTextBrowser, and QPushButton.

Definition at line 9457 of file qwidget.cpp.

Referenced by QComboBox::addItems(), event(), QAxHostWidget::focusOutEvent(), QAbstractButton::focusOutEvent(), QAbstractSpinBox::focusOutEvent(), QLabel::focusOutEvent(), QPlainTextEdit::focusOutEvent(), QGraphicsView::focusOutEvent(), QTextEdit::focusOutEvent(), QAbstractItemView::focusOutEvent(), setShown(), and QPlainTextEdit::toPlainText().

9458 {
9459  if (focusPolicy() != Qt::NoFocus || !isWindow())
9460  update();
9461 }
bool isWindow() const
Returns true if the widget is an independent window, otherwise returns false.
Definition: qwidget.h:945
Qt::FocusPolicy focusPolicy() const
void update()
Updates the widget unless updates are disabled or the widget is hidden.
Definition: qwidget.cpp:10883

◆ focusPolicy()

Qt::FocusPolicy QWidget::focusPolicy ( ) const

◆ focusPreviousChild()

bool QWidget::focusPreviousChild ( )
inlineprotected

Finds a new widget to give the keyboard focus to, as appropriate for Shift+Tab, and returns true if it can find a new widget, or false if it can't.

See also
focusNextChild()

Definition at line 731 of file qwidget.h.

731 { return focusNextPrevChild(false); }
virtual bool focusNextPrevChild(bool next)
Finds a new widget to give the keyboard focus to, as appropriate for Tab and Shift+Tab, and returns true if it can find a new widget, or false if it can&#39;t.
Definition: qwidget.cpp:6836

◆ focusProxy()

QWidget * QWidget::focusProxy ( ) const

Returns the focus proxy, or 0 if there is no focus proxy.

See also
setFocusProxy()

Definition at line 6561 of file qwidget.cpp.

Referenced by QAbstractItemViewPrivate::editor(), QWidgetPrivate::effectiveFocusWidget(), QWidgetPrivate::frameStrut(), QX11EmbedContainerPrivate::moveInputToProxy(), QAbstractItemViewPrivate::openEditor(), QApplication::qwsProcessEvent(), QX11EmbedContainerPrivate::QX11EmbedContainerPrivate(), setFocus(), setFocusProxy(), setTabOrder(), and QWinInputContext::updateImeStatus().

6562 {
6563  Q_D(const QWidget);
6564  return d->extra ? (QWidget *)d->extra->focus_proxy : 0;
6565 }
double d
Definition: qnumeric_p.h:62
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_D(Class)
Definition: qglobal.h:2482

◆ focusWidget()

QWidget * QWidget::focusWidget ( ) const

Returns the last child of this widget that setFocus had been called on.

For top level widgets this is the widget that will get focus in case this window gets activated

This is not the same as QApplication::focusWidget(), which returns the focus widget in the currently active window.

Definition at line 6863 of file qwidget.cpp.

Referenced by QGroupBoxPrivate::_q_fixFocus(), QMdiArea::addSubWindow(), QApplicationPrivate::closePopup(), QAbstractItemViewPrivate::editor(), QMotifStyle::event(), QMacStyle::event(), flipPoint(), QScrollArea::focusNextPrevChild(), QApplicationPrivate::focusNextPrevChild_helper(), QApplicationPrivate::globalEventProcessor(), hasFocus(), QGraphicsProxyWidgetPrivate::inputMethodQueryHelper(), QMdiSubWindowPrivate::leaveInteractiveMode(), QAccessibleWidget::navigate(), QApplicationPrivate::openPopup(), qt_cleanup(), qt_try_modal(), QtWndProc(), QApplication::qwsProcessEvent(), QAccessibleWidget::relationTo(), QTest::sendKeyEvent(), QGraphicsProxyWidgetPrivate::sendWidgetKeyEvent(), QWorkspaceChild::setActive(), QApplication::setActiveWindow(), setAttribute(), QMenuBarPrivate::setCurrentAction(), QStackedLayout::setCurrentIndex(), QWidgetPrivate::setEnabled_helper(), setFocus(), QMdiSubWindowPrivate::setFocusWidget(), setParent(), QDialog::setVisible(), QWidgetPrivate::show_sys(), QGraphicsViewPrivate::updateInputMethodSensitivity(), and QGraphicsProxyWidgetPrivate::updateProxyInputMethodAcceptanceFromWidget().

6864 {
6865  return const_cast<QWidget *>(d_func()->focus_child);
6866 }
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150

◆ font()

const QFont& QWidget::font ( ) const

◆ fontChange()

void QWidget::fontChange ( const QFont )
protectedvirtual
Warning
This function is not part of the public interface.

Definition at line 12003 of file qwidget.cpp.

Referenced by QStyleSheetStyle::updateStyleSheetFont().

12003 { } // compat

◆ fontInfo()

QFontInfo QWidget::fontInfo ( ) const
inline

Returns the font info for the widget's current font.

Equivalent to QFontInto(widget->font()).

See also
font(), fontMetrics(), setFont()

Definition at line 987 of file qwidget.h.

988 { return QFontInfo(data->fnt); }
QFont fnt
Definition: qwidget.h:133
QWidgetData * data
Definition: qwidget.h:815
friend class QFontInfo
Definition: qwidget.h:750

◆ fontMetrics()

QFontMetrics QWidget::fontMetrics ( ) const
inline

◆ foregroundRole()

QPalette::ColorRole QWidget::foregroundRole ( ) const

Returns the foreground role.

The foreground role defines the color from the widget's palette that is used to draw the foreground.

If no explicit foreground role is set, the function returns a role that contrasts with the background role.

See also
setForegroundRole(), backgroundRole()

Definition at line 4728 of file qwidget.cpp.

Referenced by QRenderRule::configurePalette(), QCommonStyle::drawControl(), QPainter::initFrom(), QAxClientSite::Invoke(), and QLabel::paintEvent().

4729 {
4730  Q_D(const QWidget);
4731  QPalette::ColorRole rl = QPalette::ColorRole(d->fg_role);
4732  if (rl != QPalette::NoRole)
4733  return rl;
4735  switch (backgroundRole()) {
4736  case QPalette::Button:
4737  role = QPalette::ButtonText;
4738  break;
4739  case QPalette::Base:
4740  role = QPalette::Text;
4741  break;
4742  case QPalette::Dark:
4743  case QPalette::Shadow:
4744  role = QPalette::Light;
4745  break;
4746  case QPalette::Highlight:
4748  break;
4749  case QPalette::ToolTipBase:
4750  role = QPalette::ToolTipText;
4751  break;
4752  default:
4753  ;
4754  }
4755  return role;
4756 }
double d
Definition: qnumeric_p.h:62
ColorRole
The ColorRole enum defines the different symbolic color roles used in current GUIs.
Definition: qpalette.h:93
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
QPalette::ColorRole backgroundRole() const
Returns the background role of the widget.
Definition: qwidget.cpp:4677
#define Q_D(Class)
Definition: qglobal.h:2482

◆ frameGeometry()

QRect QWidget::frameGeometry ( ) const

◆ frameSize()

QSize QWidget::frameSize ( ) const

◆ geometry()

const QRect& QWidget::geometry ( ) const

◆ getContentsMargins()

void QWidget::getContentsMargins ( int *  left,
int *  top,
int *  right,
int *  bottom 
) const

Returns the widget's contents margins for left, top, right, and bottom.

See also
setContentsMargins(), contentsRect()

Definition at line 7509 of file qwidget.cpp.

Referenced by QDockAreaLayoutItem::maximumSize(), QDockAreaLayoutItem::minimumSize(), QSplitterPrivate::setGeo(), QGraphicsProxyWidgetPrivate::setWidget_helper(), QComboBox::showPopup(), QDockWidgetLayout::sizeFromContent(), QDockAreaLayoutItem::sizeHint(), and QExpandingLineEdit::updateMinimumWidth().

7510 {
7511  Q_D(const QWidget);
7512  if (left)
7513  *left = d->leftmargin;
7514  if (top)
7515  *top = d->topmargin;
7516  if (right)
7517  *right = d->rightmargin;
7518  if (bottom)
7519  *bottom = d->bottommargin;
7520 }
double d
Definition: qnumeric_p.h:62
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_D(Class)
Definition: qglobal.h:2482
Q_CORE_EXPORT QTextStream & right(QTextStream &s)
Q_CORE_EXPORT QTextStream & left(QTextStream &s)

◆ getDC()

HDC QWidget::getDC ( ) const
virtual

Returns the window system handle of the widget, for low-level access.

Using this function is not portable.

An HDC acquired with getDC() has to be released with releaseDC().

Warning
Using this function is not portable.

Reimplemented from QPaintDevice.

Definition at line 11849 of file qwidget.cpp.

Referenced by QRasterWindowSurface::flush(), and showYellowThing_win().

11850 {
11851  Q_D(const QWidget);
11852  if (d->hd)
11853  return (HDC) d->hd;
11854  return GetDC(winId());
11855 }
double d
Definition: qnumeric_p.h:62
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_D(Class)
Definition: qglobal.h:2482
WId winId() const
Returns the window system identifier of the widget.
Definition: qwidget.cpp:2557

◆ grabGesture()

void QWidget::grabGesture ( Qt::GestureType  gesture,
Qt::GestureFlags  flags = Qt::GestureFlags() 
)

Subscribes the widget to a given gesture with specific flags.

See also
ungrabGesture(), QGestureEvent
Since
4.6

Definition at line 12964 of file qwidget.cpp.

Referenced by QGraphicsScenePrivate::addView(), and QGraphicsView::setupViewport().

12965 {
12966  Q_D(QWidget);
12967  d->gestureContext.insert(gesture, flags);
12968  (void)QGestureManager::instance(); // create a gesture manager
12969 }
double d
Definition: qnumeric_p.h:62
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_D(Class)
Definition: qglobal.h:2482
static QGestureManager * instance()

◆ grabKeyboard()

void QWidget::grabKeyboard ( )

Grabs the keyboard input.

This widget receives 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() focusWidget()

Definition at line 3338 of file qwidget_mac.mm.

Referenced by QWidgetResizeHandler::doMove(), QWidgetResizeHandler::doResize(), isServerProcess(), qstring_to_xtp(), qt_grab_cursor(), and QWhatsThisPrivate::say().

3339 {
3340  if(!qt_nograb()) {
3343  mac_keyboard_grabber = this;
3344  }
3345 }
QWidget * mac_keyboard_grabber
Definition: qwidget_mac.mm:157
bool qt_nograb()
void releaseKeyboard()
Releases the keyboard grab.

◆ grabMouse() [1/2]

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.

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
Only visible widgets can grab mouse input. If isVisible() returns false for a widget, that widget cannot call grabMouse().
(Mac OS X developers) For Cocoa, calling grabMouse() on a widget only works when the mouse is inside the frame of that widget. For Carbon, it works outside the widget's frame as well, like for Windows and X11.
See also
releaseMouse() grabKeyboard() releaseKeyboard()

Definition at line 3308 of file qwidget_mac.mm.

Referenced by QX11Data::dndEnable(), QWidgetResizeHandler::doMove(), QWidgetResizeHandler::doResize(), QWidgetResizeHandler::eventFilter(), findRealWindow(), isServerProcess(), QWidgetResizeHandler::keyPressEvent(), qJournalRecordProc(), qstring_to_xtp(), and qt_grab_cursor().

3309 {
3310  if(isVisible() && !qt_nograb()) {
3311  if(mac_mouse_grabber)
3313  mac_mouse_grabber=this;
3315  }
3316 }
QWidget * mac_mouse_grabber
Definition: qwidget_mac.mm:156
bool isVisible() const
Definition: qwidget.h:1005
bool qt_nograb()
void releaseMouse()
Releases the mouse grab.
void qt_mac_setMouseGrabCursor(bool set, QCursor *cursor=0)
Definition: qcursor_mac.mm:227

◆ grabMouse() [2/2]

void QWidget::grabMouse ( const QCursor cursor)

Definition at line 3319 of file qwidget_mac.mm.

3320 {
3321  if(isVisible() && !qt_nograb()) {
3322  if(mac_mouse_grabber)
3324  mac_mouse_grabber=this;
3325  qt_mac_setMouseGrabCursor(true, const_cast<QCursor *>(&cursor));
3326  }
3327 }
QWidget * mac_mouse_grabber
Definition: qwidget_mac.mm:156
bool isVisible() const
Definition: qwidget.h:1005
bool qt_nograb()
void releaseMouse()
Releases the mouse grab.
void qt_mac_setMouseGrabCursor(bool set, QCursor *cursor=0)
Definition: qcursor_mac.mm:227

◆ grabShortcut()

int QWidget::grabShortcut ( const QKeySequence key,
Qt::ShortcutContext  context = Qt::WindowShortcut 
)

Adds a shortcut to Qt's shortcut system that watches for the given key sequence in the given context.

If the context is Qt::ApplicationShortcut, the shortcut applies to the application as a whole. Otherwise, it is either local to this widget, Qt::WidgetShortcut, or to the window itself, Qt::WindowShortcut.

If the same key sequence has been grabbed by several widgets, when the key sequence occurs a QEvent::Shortcut event is sent to all the widgets to which it applies in a non-deterministic order, but with the ``ambiguous'' flag set to true.

Warning
You should not normally need to use this function; instead create QAction with the shortcut key sequences you require (if you also want equivalent menu options and toolbar buttons), or create QShortcut if you just need key sequences. Both QAction and QShortcut handle all the event filtering for you, and provide signals which are triggered when the user triggers the key sequence, so are much easier to use than this low-level function.
See also
releaseShortcut() setShortcutEnabled()

Definition at line 11747 of file qwidget.cpp.

Referenced by QTabBar::insertTab(), QAbstractButton::setShortcut(), QTabBar::setTabText(), and QGroupBox::setTitle().

11748 {
11749  Q_ASSERT(qApp);
11750  if (key.isEmpty())
11751  return 0;
11753  return qApp->d_func()->shortcutMap.addShortcut(this, key, context);
11754 }
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define qApp
bool isEmpty() const
Returns true if the key sequence is empty; otherwise returns false.
void setAttribute(Qt::WidgetAttribute, bool on=true)
Sets the attribute attribute on this widget if on is true; otherwise clears the attribute.
Definition: qwidget.cpp:11087

◆ graphicsEffect()

QGraphicsEffect * QWidget::graphicsEffect ( ) const

The graphicsEffect function returns a pointer to the widget's graphics effect.

If the widget has no graphics effect, 0 is returned.

Since
4.6
See also
setGraphicsEffect()

Definition at line 5484 of file qwidget.cpp.

Referenced by QWidgetPrivate::clipToEffectiveMask(), QWidgetPrivate::drawWidget(), QWidgetPrivate::invalidateGraphicsEffectsRecursively(), QWidgetPrivate::isOverlapped(), QWidgetBackingStore::markDirty(), QWidgetPrivate::subtractOpaqueSiblings(), and QWidgetPrivate::updateIsOpaque().

5485 {
5486  Q_D(const QWidget);
5487  return d->graphicsEffect;
5488 }
double d
Definition: qnumeric_p.h:62
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_D(Class)
Definition: qglobal.h:2482

◆ graphicsProxyWidget()

QGraphicsProxyWidget * QWidget::graphicsProxyWidget ( ) const

Returns the proxy widget for the corresponding embedded widget in a graphics view; otherwise returns 0.

Since
4.5
See also
QGraphicsProxyWidget::createProxyForChildWidget(), QGraphicsScene::addWidget()

Definition at line 12939 of file qwidget.cpp.

Referenced by QGraphicsProxyWidget::createProxyForChildWidget(), QApplicationPrivate::dispatchEnterLeave(), QComboBoxPrivateContainer::hideEvent(), QApplication::setActiveWindow(), QApplicationPrivate::setFocusWidget(), setParent(), and setWindowOpacity().

12940 {
12941  Q_D(const QWidget);
12942  if (d->extra) {
12943  return d->extra->proxyWidget;
12944  }
12945  return 0;
12946 }
double d
Definition: qnumeric_p.h:62
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_D(Class)
Definition: qglobal.h:2482

◆ hasFocus()

bool QWidget::hasFocus ( ) const

Definition at line 6583 of file qwidget.cpp.

Referenced by QFileDialogPrivate::_q_autoCompleteFileName(), QFileDialogPrivate::_q_selectionChanged(), clearFocus(), QAbstractItemView::closeEditor(), QColorWell::dragLeaveEvent(), QTreeView::drawRow(), QLineEdit::event(), QX11EmbedContainer::eventFilter(), QAxHostWidget::eventFilter(), QMacStylePrivate::eventFilter(), QComboBox::hidePopup(), QStyleOption::init(), QMenuBar::initStyleOption(), QComboBox::initStyleOption(), QLineEdit::inputMethodEvent(), QGraphicsProxyWidgetPrivate::inputMethodQueryHelper(), QAbstractButton::keyPressEvent(), QAbstractItemView::keyPressEvent(), QMenuBar::leaveEvent(), make_widget_eventUPP(), QAccessibleWidget::navigate(), QWellArray::paintCell(), QListView::paintEvent(), QLineEdit::paintEvent(), QtWndProc(), resetInputContext(), QMdiSubWindowPrivate::restoreFocus(), QWorkspaceChild::setActive(), setAttribute(), QLineEdit::setCompleter(), QLineEdit::setEchoMode(), QLineEdit::setPlaceholderText(), QGraphicsView::setScene(), QDialog::setVisible(), QMdiSubWindow::showShaded(), QAccessibleWidget::state(), QAccessibleTabBar::state(), QAccessibleTitleBar::state(), QMacStylePrivate::timerEvent(), QAbstractItemView::viewOptions(), and QX11EmbedContainer::x11Event().

6584 {
6585  const QWidget* w = this;
6586  while (w->d_func()->extra && w->d_func()->extra->focus_proxy)
6587  w = w->d_func()->extra->focus_proxy;
6588  if (QWidget *window = w->window()) {
6589 #ifndef QT_NO_GRAPHICSVIEW
6590  QWExtra *e = window->d_func()->extra;
6591  if (e && e->proxyWidget && e->proxyWidget->hasFocus() && window->focusWidget() == w)
6592  return true;
6593 #endif
6594  }
6595  return (QApplication::focusWidget() == w);
6596 }
bool hasFocus() const
Returns true if this item is active, and it or its focus proxy has keyboard input focus; otherwise...
QWidget * focusWidget() const
Returns the last child of this widget that setFocus had been called on.
Definition: qwidget.cpp:6863
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
QGraphicsProxyWidget * proxyWidget
Definition: qwidget_p.h:251
QWidget * window() const
Returns the window for this widget, i.e.
Definition: qwidget.cpp:4492
static QWidget * focusWidget()
Returns the application widget that has the keyboard input focus, or 0 if no widget in this applicati...

◆ hasMouseTracking()

bool QWidget::hasMouseTracking ( ) const
inline

Definition at line 993 of file qwidget.h.

Referenced by axc_FilterProc(), QAbstractScrollArea::event(), QApplicationPrivate::globalEventProcessor(), and QApplication::notify().

bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041

◆ height()

int QWidget::height ( ) const
inline

Referenced by QWorkspacePrivate::_q_scrollBarChanged(), QCalendarWidgetPrivate::_q_yearClicked(), QDialog::adjustPosition(), QApplicationPrivate::applyX11SpecificCommandLineArguments(), QWorkspace::cascade(), QGraphicsView::centerOn(), QAbstractSpinBox::contextMenuEvent(), QWSDisplay::defineCursor(), QColumnViewPrivate::doLayout(), QTreeView::drawRow(), QGraphicsView::ensureVisible(), QWorkspace::eventFilter(), QWorkspaceChild::eventFilter(), QWizardPrivate::findDefaultBackgroundPixmap(), QMenuBar::heightForWidth(), QTreeView::indexRowSizeHint(), QColorDialogPrivate::init(), inputMethodQuery(), QTreeViewPrivate::itemHeight(), QMenu::keyPressEvent(), QDialog::minimumSizeHint(), QProgressBar::minimumSizeHint(), QRubberBand::move(), move(), QWorkspace::paintEvent(), QMenuBar::paintEvent(), QListView::paintEvent(), QMenu::paintEvent(), QWizard::paintEvent(), QTabBar::paintEvent(), QHeaderView::paintEvent(), QWizardHeader::paintEvent(), QWizardAntiFlickerWidget::paintEvent(), QColorLuminancePicker::paintEvent(), QGLOverlayWidget::paintGL(), QMdiAreaPrivate::place(), QTipLabel::placeTip(), QtWndProc(), QAccessibleTable2::rect(), QAccessibleHeader::rect(), QAccessibleItemView::rect(), QAccessibleSlider::rect(), QAccessibleDial::rect(), QAccessibleTable2HeaderCell::rect(), QComboBoxListView::resizeEvent(), QX11EmbedContainer::resizeEvent(), QMdiSubWindow::resizeEvent(), QColorPicker::resizeEvent(), QAxHostWidget::resizeObject(), QExpandingLineEdit::resizeToContents(), QMdiAreaPrivate::resizeToMinimumTileSize(), QTableView::rowMoved(), QWhatsThisPrivate::say(), QMenuPrivate::scrollerHeight(), QProgressDialog::setBar(), QProgressDialog::setCancelButton(), QProgressDialog::setCancelButtonText(), setFixedWidth(), setGeometry(), QProgressDialog::setLabel(), QProgressDialog::setLabelText(), setMaximumSize(), setMaximumWidth(), setMinimumSize(), setMinimumWidth(), QMdiSubWindowPrivate::setSizeGrip(), QProgressDialog::setValue(), QVistaHelper::setWindowPosHack(), QDial::setWrapping(), QMdiSubWindowPrivate::showButtonsInMenuBar(), QProgressDialog::showEvent(), QWhatsThat::showEvent(), QDialog::showExtension(), QComboBox::showPopup(), QWorkspaceChild::showShaded(), QVistaBackButton::sizeHint(), QDialog::sizeHint(), QAbstractScrollArea::sizeHint(), QProgressDialog::sizeHint(), CloseButton::sizeHint(), QFileDialogListView::sizeHint(), QFileDialogTreeView::sizeHint(), QTableView::sizeHintForRow(), QAbstractItemView::sizeHintForRow(), QWorkspace::tile(), QTableView::updateGeometries(), QListView::updateGeometries(), QTreeViewPrivate::updateScrollBars(), QMessageBoxPrivate::updateSize(), QMdiAreaPrivate::updateTabBarGeometry(), QColorLuminancePicker::val2y(), QTableView::visualRegionForSelection(), QTreeView::visualRegionForSelection(), QHeaderView::visualRegionForSelection(), windowInteractsWithPosition(), and QColorLuminancePicker::y2val().

◆ heightForWidth()

int QWidget::heightForWidth ( int  w) const
virtual

Returns the preferred height for this widget, given the width w.

If this widget has a layout, the default implementation returns the layout's preferred height. if there is no layout, the default implementation returns -1 indicating that the preferred height does not depend on the width.

Reimplemented in QTabWidget, QLabel, QMenuBar, and QCommandLinkButton.

Definition at line 10241 of file qwidget.cpp.

Referenced by QLabel::heightForWidth(), menuBarHeightForWidth(), and QScrollAreaPrivate::updateScrollBars().

10242 {
10243  if (layout() && layout()->hasHeightForWidth())
10244  return layout()->totalHeightForWidth(w);
10245  return -1;
10246 }
int totalHeightForWidth(int w) const
Also takes contentsMargins and menu bar into account.
Definition: qlayout.cpp:823
QLayout * layout() const
Returns the layout manager that is installed on this widget, or 0 if no layout manager is installed...
Definition: qwidget.cpp:10073

◆ hide

void QWidget::hide ( )
inlineslot

Hides the widget.

This function is equivalent to setVisible(false).

Note
If you are working with QDialog or its subclasses and you invoke the show() function after this function, the dialog will be displayed in its original position.
See also
hideEvent(), isHidden(), show(), setVisible(), isVisible(), close()

Definition at line 501 of file qwidget.h.

Referenced by QWizardPrivate::_q_updateButtonStates(), QCalendarWidgetPrivate::_q_yearClicked(), QCalendarWidgetPrivate::_q_yearEditingFinished(), QAxClientSite::activateObject(), QAxServerBase::ActiveXProc(), QMainWindow::addDockWidget(), QMainWindowLayout::applyState(), QLineControl::complete(), QToolBarLayout::createItem(), QCalendarWidgetPrivate::createNavigationBar(), QEgl::createSurface(), QWidgetAction::deleteWidget(), QAccessibleMenu::doAction(), QAccessibleMenuBar::doAction(), QAccessibleMenuItem::doAction(), QDialog::done(), QWizardPrivate::ensureButton(), QInputDialogPrivate::ensureComboBox(), QInputDialogPrivate::ensureDoubleSpinBox(), QInputDialogPrivate::ensureIntSpinBox(), QInputDialogPrivate::ensureLineEdit(), QInputDialogPrivate::ensureListView(), event(), QFocusFrame::eventFilter(), QBalloonTip::hideBalloon(), QWorkspacePrivate::hideChild(), QStatusBar::hideOrShow(), QMdiAreaPrivate::hideRubberBand(), QTabBarPrivate::init(), QToolBox::insertItem(), QStatusBar::insertWidget(), QStackedLayout::insertWidget(), QAxServerBase::internalActivate(), QScriptDebuggerCodeFinderWidget::keyPressEvent(), QScriptNewBreakpointWidget::keyPressEvent(), QFileDialogLineEdit::keyPressEvent(), QDialogButtonBoxPrivate::layoutButtons(), QTabBarPrivate::layoutTabs(), QMdiSubWindowPrivate::leaveRubberBandMode(), QListWidgetItem::listWidget(), make_win_eventUPP(), QWorkspacePrivate::minimizeWindow(), QSplashScreen::mousePressEvent(), mousePressEvent(), QGLOverlayWidget::paintGL(), QLineControl::processKeyEvent(), QColorShower::QColorShower(), QComboBoxPrivateContainer::QComboBoxPrivateContainer(), QMainWindowLayout::QMainWindowLayout(), QScriptDebuggerCodeFinderWidget::QScriptDebuggerCodeFinderWidget(), QScriptNewBreakpointWidget::QScriptNewBreakpointWidget(), qt_mac_unregister_widget(), qt_x11_recreateWidget(), QToolBarLayout::QToolBarLayout(), QApplication::qwsProcessEvent(), QAbstractItemViewPrivate::releaseEditor(), QMdi::ControlContainer::removeButtonsFromMenuBar(), QMainWindow::removeDockWidget(), QWorkspacePrivate::removeIcon(), QMainWindow::removeToolBar(), QStatusBar::removeWidget(), QAlphaWidget::render(), QTreeViewPrivate::renderTreeToPixmapForAnimation(), QProgressDialog::reset(), QDockAreaLayoutInfo::restoreState(), QRollEffect::scroll(), QWizardPrivate::setButtonLayout(), QProgressDialog::setCancelButton(), QAbstractScrollArea::setCornerWidget(), QMenuBarPrivate::setCurrentAction(), QStackedLayout::setCurrentIndex(), QDialog::setExtension(), QToolBarLayout::setGeometry(), QMessageBox::setInformativeText(), QInputDialogPrivate::setInputWidget(), QTreeWidget::setItemHidden(), QProgressDialog::setLabel(), QMainWindow::setMenuBar(), QWizard::setPage(), setParent(), QCompleter::setPopup(), QColumnViewPrivate::setPreviewWidget(), QDeclarativeView::setRootObject(), QFocusFrame::setWidget(), QDockWidgetLayout::setWidgetForRole(), QMdi::ControlContainer::showButtonsInMenuBar(), QScriptEngineDebugger::standardWindow(), QToolBarLayout::takeAt(), QStackedLayout::takeAt(), QETWidget::translateWheelEvent(), QGLContext::updatePaintDevice(), QComboBoxPrivateContainer::updateScrollers(), QDockAreaLayout::updateSeparatorWidgets(), QDialog::~QDialog(), and ~QWidget().

501 { setVisible(false); }
virtual void setVisible(bool visible)
Definition: qwidget.cpp:7991

◆ hideEvent()

void QWidget::hideEvent ( QHideEvent event)
protectedvirtual

This event handler can be reimplemented in a subclass to receive widget hide events.

The event is passed in the event parameter.

Hide events are sent to widgets immediately after they have been hidden.

Note: 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. After receiving a spontaneous hide event, a widget is still considered visible in the sense of isVisible().

See also
visible, event(), QHideEvent

Reimplemented in QComboBoxPrivateContainer, QComboBox, QTabBar, QComboBoxPrivateScroller, QMenu, QCalendarPopup, QAbstractSpinBox, QX11EmbedContainer, QMdiSubWindow, QWorkspace, QScrollBar, QSizeGrip, and QWSEmbedWidget.

Definition at line 9864 of file qwidget.cpp.

Referenced by QComboBox::addItems(), event(), QWidgetPrivate::hide_helper(), QSizeGrip::hideEvent(), QAbstractSpinBox::hideEvent(), and setShown().

9865 {
9866 }

◆ inputContext()

QInputContext * QWidget::inputContext ( )

This function returns the QInputContext for this widget.

By default the input context is inherited from the widgets parent. For toplevels it is inherited from QApplication.

You can override this and set a special input context for this widget by using the setInputContext() method.

See also
setInputContext()

Definition at line 474 of file qwidget.cpp.

Referenced by QLineEdit::createStandardContextMenu(), QMacInputContext::globalEventProcessor(), QBBScreenEventHandler::handleKeyboardEvent(), QApplication::notify(), qt_keyrelease_scanner(), QtWndProc(), QDeclarativeTextInputPrivate::sendMouseEventToInputContext(), setAttribute(), QWidgetPrivate::setEnabled_helper(), QGraphicsScenePrivate::setFocusItemHelper(), QApplicationPrivate::setFocusWidget(), QGraphicsItem::setInputMethodHints(), setInputMethodHints(), QComboBox::showPopup(), QWSInputContext::translateIMEvent(), updateMicroFocus(), and QApplication::x11ProcessEvent().

475 {
476  Q_D(QWidget);
478  return 0;
479 
480  return d->inputContext();
481 }
double d
Definition: qnumeric_p.h:62
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_D(Class)
Definition: qglobal.h:2482
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041

◆ inputMethodEvent()

void QWidget::inputMethodEvent ( QInputMethodEvent event)
protectedvirtual

This event handler, for event event, can be reimplemented in a subclass to receive Input Method composition events.

This handler is called when the state of the input method changes.

Note that when creating custom text editing widgets, the Qt::WA_InputMethodEnabled window attribute must be set explicitly (using the setAttribute() function) in order to receive input method events.

The default implementation calls event->ignore(), which rejects the Input Method event. See the QInputMethodEvent documentation for more details.

See also
event(), QInputMethodEvent

Reimplemented in QAbstractItemView, QTextEdit, QGraphicsView, QPlainTextEdit, QComboBox, and QLineEdit.

Definition at line 9668 of file qwidget.cpp.

Referenced by QComboBox::addItems(), event(), setShown(), and QPlainTextEdit::toPlainText().

9669 {
9670  event->ignore();
9671 }

◆ inputMethodHints()

Qt::InputMethodHints QWidget::inputMethodHints ( ) const

◆ inputMethodQuery()

QVariant QWidget::inputMethodQuery ( Qt::InputMethodQuery  query) const
virtual

This method is only relevant for input widgets.

It is used by the input method to query a set of properties of the widget to be able to support complex input method operations as support for surrounding text and reconversions.

query specifies which property is queried.

See also
inputMethodEvent(), QInputMethodEvent, QInputContext, inputMethodHints

Reimplemented in QTextEdit, QPlainTextEdit, QComboBox, QLineEdit, QAbstractItemView, QGraphicsView, and QAbstractSpinBox.

Definition at line 9683 of file qwidget.cpp.

Referenced by QComboBox::addItems(), QBBInputContext::dispatchRequestSoftwareInputPanel(), QScrollArea::ensureWidgetVisible(), event(), QMacInputContext::globalEventProcessor(), QBBInputContext::hasSelectedText(), QAbstractItemView::inputMethodQuery(), QComboBox::inputMethodQuery(), QGraphicsProxyWidgetPrivate::inputMethodQueryHelper(), QBBInputContext::onGetCursorPosition(), QBBInputContext::onGetSelectedText(), QBBInputContext::onGetTextAfterCursor(), QBBInputContext::onGetTextBeforeCursor(), QBBInputContext::onSetComposingRegion(), qt_keyrelease_scanner(), QtWndProc(), QWinInputContext::reconvertString(), setShown(), QPlainTextEdit::toPlainText(), QWSInputContext::translateIMQueryEvent(), QWinInputContext::update(), and QXIMInputContext::update().

9684 {
9685  switch(query) {
9686  case Qt::ImMicroFocus:
9687  return QRect(width()/2, 0, 1, height());
9688  case Qt::ImFont:
9689  return font();
9690  case Qt::ImAnchorPosition:
9691  // Fallback.
9693  default:
9694  return QVariant();
9695  }
9696 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
virtual QVariant inputMethodQuery(Qt::InputMethodQuery) const
This method is only relevant for input widgets.
Definition: qwidget.cpp:9683
int height() const
int width() const
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
const QFont & font() const

◆ insertAction()

void QWidget::insertAction ( QAction before,
QAction action 
)

Inserts the action action to this widget's list of actions, before the action before.

It appends the action if before is 0 or before is not a valid action for this widget.

A QWidget should only have one of each action.

See also
removeAction(), addAction(), QMenu, contextMenuPolicy, actions()

Definition at line 3342 of file qwidget.cpp.

Referenced by addAction(), addActions(), QAbstractSpinBox::contextMenuEvent(), QMenuBar::defaultAction(), insertActions(), QMenuBar::insertMenu(), QMenu::insertMenu(), QMenuBar::insertSeparator(), QMenu::insertSeparator(), QToolBar::insertSeparator(), QToolBar::insertWidget(), QMenu::setSeparatorsCollapsible(), and QTornOffMenu::syncWithMenu().

3343 {
3344  if(!action) {
3345  qWarning("QWidget::insertAction: Attempt to insert null action");
3346  return;
3347  }
3348 
3349  Q_D(QWidget);
3350  if(d->actions.contains(action))
3351  removeAction(action);
3352 
3353  int pos = d->actions.indexOf(before);
3354  if (pos < 0) {
3355  before = 0;
3356  pos = d->actions.size();
3357  }
3358  d->actions.insert(pos, action);
3359 
3360  QActionPrivate *apriv = action->d_func();
3361  apriv->widgets.append(this);
3362 
3363  QActionEvent e(QEvent::ActionAdded, action, before);
3364  QApplication::sendEvent(this, &e);
3365 }
QPoint pos() const
double d
Definition: qnumeric_p.h:62
QList< QWidget * > widgets
Definition: qaction_p.h:121
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
The QActionEvent class provides an event that is generated when a QAction is added, removed, or changed.
Definition: qevent.h:632
#define Q_D(Class)
Definition: qglobal.h:2482
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
Q_CORE_EXPORT void qWarning(const char *,...)
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
void removeAction(QAction *action)
Removes the action action from this widget&#39;s list of actions.
Definition: qwidget.cpp:3386

◆ insertActions()

void QWidget::insertActions ( QAction before,
QList< QAction *>  actions 
)

Inserts the actions actions to this widget's list of actions, before the action before.

It appends the action if before is 0 or before is not a valid action for this widget.

A QWidget can have at most one of each action.

See also
removeAction(), QMenu, insertAction(), contextMenuPolicy

Definition at line 3376 of file qwidget.cpp.

3377 {
3378  for(int i = 0; i < actions.count(); ++i)
3379  insertAction(before, actions.at(i));
3380 }
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
void insertAction(QAction *before, QAction *action)
Inserts the action action to this widget&#39;s list of actions, before the action before.
Definition: qwidget.cpp:3342

◆ internalWinId()

WId QWidget::internalWinId ( ) const
inline

Returns the window system identifier of the widget, or 0 if the widget is not created yet.

Warning
This function is not part of the public interface.

Definition at line 244 of file qwidget.h.

Referenced by QX11PaintEngine::begin(), QPainter::begin(), clearFocus(), clipboardData(), create(), QWidgetPrivate::createWinId(), destroy(), do_size_hints(), QOleDropTarget::DragOver(), QWindowsVistaStyle::drawComplexControl(), effectiveWinId(), QX11EmbedContainer::embedClient(), QX11EmbedWidget::embedInto(), QClipboardWatcher::empty(), QX11EmbedWidget::event(), QX11EmbedContainer::event(), QX11Data::findClientWindow(), flipPoint(), ShivaVGWindowSurface::flush(), QVGWindowSurface::flush(), QGLWindowSurface::flush(), QClipboardWatcher::getDataInFormat(), getNetWmState(), QWidgetPrivate::hide_sys(), QWidgetPrivate::hideChildren(), QKeyMapperPrivate::isADeadKey(), QApplicationPrivate::isAlien(), QWidgetPrivate::isBackgroundInherited(), isProcessBeingDebugged(), isServerProcess(), QWidgetPrivate::mapFromGlobal(), QWidgetBackingStore::markDirtyOnScreen(), QX11Data::motifdndEnable(), QX11Data::motifdndObtainData(), QSizeGrip::mouseMoveEvent(), QX11EmbedContainerPrivate::moveInputToProxy(), nativeParentWidget(), QWidgetPrivate::paintSiblingsRecursive(), QApplicationPrivate::pickMouseReceiver(), previousInFocusChain(), qstring_to_xtp(), qt_change_net_wm_state(), qt_check_clipboard_sentinel(), qt_check_selection_sentinel(), qt_grab_cursor(), qt_insert_sip(), qt_isGenuineQWidget(), qt_mac_nativeview_for(), qt_net_remove_user_time(), qt_net_update_user_time(), qt_qpa_set_cursor(), qt_show_system_menu(), qt_try_modal(), qt_win_set_cursor(), qt_x11_enforce_cursor(), qt_x11_recreateNativeWidgetsRecursive(), qt_x11_wait_for_window_manager(), qt_xfixes_clipboard_changed(), qt_xfixes_selection_changed(), QtCeGetClipboard(), QtCeSetClipboard(), QtWndProc(), QX11EmbedContainer::QX11EmbedContainer(), QX11EmbedWidget::QX11EmbedWidget(), QWidgetBackingStoreTracker::registerWidget(), releaseDC(), QWSDisplay::selectCursor(), QApplicationPrivate::sendMouseEvent(), QApplicationPrivate::sendSyntheticEnterLeave(), setAttribute(), setFocus(), QWSInputContext::setFocusWidget(), QWidgetPrivate::setNetWmWindowTypes(), QWSDisplay::setWindowCaption(), QWidgetPrivate::show_sys(), QWhatsThat::showEvent(), QWidgetBackingStore::showYellowThing(), QWidgetBackingStore::sync(), QETWidget::translateGestureEvent(), translateKeySym(), QETWidget::translateMouseEvent(), QETWidget::translateTabletEvent(), QETWidget::translateWheelEvent(), QApplication::winFocus(), QWSWindowSurface::winId(), winId(), QWindowsXPStylePrivate::winId(), QApplication::x11ClientMessage(), QX11EmbedWidget::x11Event(), QX11EmbedContainer::x11Event(), QApplication::x11ProcessEvent(), xdndEnable(), QX11Data::xdndHandleDrop(), ~QWidget(), QX11EmbedContainer::~QX11EmbedContainer(), and QX11EmbedWidget::~QX11EmbedWidget().

244 { return data->winid; }
QWidgetData * data
Definition: qwidget.h:815
WId winid
Definition: qwidget.h:117

◆ isActiveWindow()

bool QWidget::isActiveWindow ( ) const

◆ isAncestorOf()

bool QWidget::isAncestorOf ( const QWidget child) const

Returns true if this widget is a parent, (or grandparent and so on to any level), of the given child, and both widgets are within the same window; otherwise returns false.

Definition at line 8573 of file qwidget.cpp.

Referenced by QMdiSubWindowPrivate::_q_processFocusChanged(), QGestureManager::cancelGesturesForChildren(), QWidgetBackingStore::dirtyRegion(), flipPoint(), QApplicationPrivate::focusNextPrevChild_helper(), iWantTheFocus(), QWidgetBackingStore::moveStaticWidgets(), qt_cleanup(), QWidgetPrivate::reparentFocusWidgets(), QApplicationPrivate::sendSyntheticEnterLeave(), QMdiSubWindowPrivate::setActive(), QStackedLayout::setCurrentIndex(), QMdiSubWindowPrivate::setFocusWidget(), QMdiSubWindowPrivate::setMaximizeMode(), setParent(), QMdiSubWindow::showShaded(), QAccessibleMdiSubWindow::state(), QWidgetBackingStore::staticContents(), QDirectFBWindowSurface::surfaceForWidget(), and QApplicationPrivate::translateRawTouchEvent().

8574 {
8575  while (child) {
8576  if (child == this)
8577  return true;
8578  if (child->isWindow())
8579  return false;
8580  child = child->parentWidget();
8581  }
8582  return false;
8583 }
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
bool isWindow() const
Returns true if the widget is an independent window, otherwise returns false.
Definition: qwidget.h:945

◆ isEnabled()

bool QWidget::isEnabled ( ) const
inline

Definition at line 948 of file qwidget.h.

Referenced by QPrintDialogPrivate::_q_printerOrFileSelected(), QGroupBoxPrivate::_q_setChildrenEnabled(), QComboBox::addItems(), QAbstractButton::animateClick(), QGroupBox::changeEvent(), QAbstractButton::changeEvent(), QAbstractSpinBox::changeEvent(), QAbstractSlider::changeEvent(), QMenu::changeEvent(), QComboBox::changeEvent(), QPlainTextEdit::changeEvent(), QTextEdit::changeEvent(), QGroupBox::childEvent(), QAbstractButton::click(), QShortcutMap::correctWidgetContext(), QXIMInputContext::create_xim(), QApplicationPrivate::dispatchEnterLeave(), QAccessibleTabBar::doAction(), QGraphicsProxyWidget::dragMoveEvent(), QTreeView::drawBranches(), QWindowsXPStyle::drawComplexControl(), QCommonStyle::drawPrimitive(), QGtkStyle::drawPrimitive(), QVistaBackButton::enterEvent(), QDockWidgetTitleButton::enterEvent(), CloseButton::enterEvent(), QScrollBar::event(), QAbstractButton::event(), QMessageBox::event(), event(), QAxServerBase::eventFilter(), QGraphicsProxyWidgetPrivate::findFocusChild(), QAbstractItemView::focusNextPrevChild(), QApplicationPrivate::focusNextPrevChild_helper(), QCalendarModel::formatForCell(), QWidgetPrivate::frameStrut(), QX11EmbedWidgetPrivate::getFocusWidget(), QApplicationPrivate::giveFocusAccordingToFocusPolicy(), QApplicationPrivate::globalEventProcessor(), QStyleOption::init(), QMenuBar::initStyleOption(), QMenu::initStyleOption(), QHeaderView::initStyleOption(), QAxClientSite::Invoke(), QKeyMapperPrivate::isADeadKey(), QToolBox::isItemEnabled(), QDialog::keyPressEvent(), QVistaBackButton::leaveEvent(), QDockWidgetTitleButton::leaveEvent(), CloseButton::leaveEvent(), QAbstractButtonPrivate::moveFocus(), QApplication::notify(), QScriptDebuggerLocalsItemDelegate::paint(), QCommandLinkButton::paintEvent(), QVistaBackButton::paintEvent(), QDockWidgetTitleButton::paintEvent(), QLabel::paintEvent(), QSplitterHandle::paintEvent(), CloseButton::paintEvent(), QHeaderView::paintSection(), paintSep(), QMenuBarPrivate::popupAction(), qt_keyrelease_scanner(), qt_try_modal(), qt_x11_enforce_cursor(), QTornOffMenu::QTornOffMenu(), QtWndProc(), QKeyMapper::sendKeyEvent(), setAttribute(), setDisabledStyle(), setFocus(), QApplicationPrivate::setFocusWidget(), setForegroundRole(), setParent(), QGraphicsProxyWidgetPrivate::setWidget_helper(), QAccessibleWidget::state(), QAccessibleMdiSubWindow::state(), QAccessibleTabBar::state(), QAccessibleTitleBar::state(), QWindowsXPStyle::styleHint(), QWizardPrivate::switchToPage(), QMacStylePrivate::timerEvent(), QETWidget::translateKeyEvent(), QETWidget::translateMouseEvent(), QWinInputContext::updateImeStatus(), QGraphicsView::viewportEvent(), and QApplication::x11ProcessEvent().

949 { return !testAttribute(Qt::WA_Disabled); }
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041

◆ isEnabledTo()

bool QWidget::isEnabledTo ( QWidget ancestor) const

Returns true if this widget would become enabled if ancestor is enabled; otherwise returns 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
setEnabled() enabled

Definition at line 3290 of file qwidget.cpp.

3291 {
3292  const QWidget * w = this;
3294  && !w->isWindow()
3295  && w->parentWidget()
3296  && w->parentWidget() != ancestor)
3297  w = w->parentWidget();
3298  return !w->testAttribute(Qt::WA_ForceDisabled);
3299 }
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
bool isWindow() const
Returns true if the widget is an independent window, otherwise returns false.
Definition: qwidget.h:945
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041

◆ isEnabledToTLW()

bool QWidget::isEnabledToTLW ( ) const
inline

This function is deprecated.

It is equivalent to isEnabled()

Definition at line 954 of file qwidget.h.

955 { return isEnabled(); }
bool isEnabled() const
Definition: qwidget.h:948

◆ isFullScreen()

bool QWidget::isFullScreen ( ) const

◆ isHidden()

bool QWidget::isHidden ( ) const
inline

Returns true if the widget is hidden, otherwise returns false.

A hidden widget will only become visible when show() is called on it. It will not be automatically shown when the parent is shown.

To check visibility, use !isVisible() instead (notice the exclamation mark).

isHidden() implies !isVisible(), but a widget can be not visible and not hidden at the same time. This is the case for widgets that are children of widgets that are not visible.

Widgets are hidden if:

  • they were created as independent windows,
  • they were created as children of visible widgets,
  • hide() or setVisible(false) was called.

Definition at line 1008 of file qwidget.h.

Referenced by QMdiAreaPrivate::_q_currentTabChanged(), QWidgetPrivate::activateChildLayoutsRecursively(), QMdiAreaPrivate::activateWindow(), QLayout::addChildWidget(), QSplitterPrivate::addContribution(), QAbstractScrollArea::addScrollBarWidget(), QDockAreaLayoutInfo::apply(), QAccessibleWidget::childAt(), QAccessibleMainWindow::childAt(), QWidgetPrivate::childAtRecursiveHelper(), QSplitter::childEvent(), QWorkspace::closeAllWindows(), QMdiAreaTabBar::contextMenuEvent(), QColumnViewPrivate::createColumn(), QWidgetPrivate::createRecursively(), do_size_hints(), QSplitterPrivate::doMove(), QSplitterPrivate::doResize(), QMdiSubWindowPrivate::drawTitleBarWhenMaximized(), QToolBar::event(), QMainWindow::event(), event(), QSizeGrip::eventFilter(), QSystemTrayIconSys::findIconGeometry(), QSplitterPrivate::findWidgetJustBeforeOrJustAfter(), QStatusBar::insertPermanentWidget(), QStatusBar::insertWidget(), QSplitterPrivate::insertWidget_helper(), QMdiAreaPrivate::internalRaise(), QWorkspaceChild::internalRaise(), QTreeWidget::isItemHidden(), isVisibleTo(), QWorkspaceChild::isWindowOrIconVisible(), QToolBarLayout::layoutActions(), QListWidgetItem::listWidget(), QTabBarPrivate::makeVisible(), menuBarHeightForWidth(), QSplitter::minimumSizeHint(), QAbstractButtonPrivate::moveFocus(), QSplitter::moveSplitter(), QMdiAreaPrivate::nextVisibleSubWindow(), QTableView::paintEvent(), QWidgetPrivate::paintSiblingsRecursive(), QPlaceHolderItem::QPlaceHolderItem(), QAxServerBase::qt_metacall(), QSplitterPrivate::recalc(), QMainWindowLayout::removeFromMacToolbar(), QToolBarAreaLayout::saveState(), QListViewPrivate::selectAll(), QWidgetAction::setDefaultWidget(), setDisabled(), setFocus(), QApplicationPrivate::setFocusWidget(), QSplitterPrivate::setGeo(), QToolBarLayout::setGeometry(), QFontDialogPrivate::setVisible_sys(), QWorkspaceChild::show(), QComboBox::showPopup(), QSplitter::sizeHint(), QWorkspace::tile(), QWorkspacePrivate::updateWorkspace(), QListView::visualRegionForSelection(), and waitForPopup().

bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041

◆ isLeftToRight()

bool QWidget::isLeftToRight ( ) const
inline

◆ isMaximized()

bool QWidget::isMaximized ( ) const

◆ isMinimized()

bool QWidget::isMinimized ( ) const

◆ isModal()

bool QWidget::isModal ( ) const
inline

◆ isRightToLeft()

bool QWidget::isRightToLeft ( ) const
inline
Warning
This function is not part of the public interface.

Definition at line 428 of file qwidget.h.

Referenced by QGraphicsView::centerOn(), QSplitterHandle::closestLegalPosition(), QWellArray::columnAt(), QWellArray::columnX(), QGridLayoutPrivate::distribute(), QTreeView::drawBranches(), QTreeView::drawRow(), QWorkspace::eventFilter(), QDateTimeEdit::focusInEvent(), QTreeView::indexRowSizeHint(), QMenuBar::keyPressEvent(), QAbstractSlider::keyPressEvent(), QMenu::keyPressEvent(), QTabWidget::keyPressEvent(), QTabBar::keyPressEvent(), QColumnViewGrip::mouseDoubleClickEvent(), QTabBar::mouseMoveEvent(), QGraphicsView::mouseMoveEvent(), QColumnView::moveCursor(), QTableView::moveCursor(), QTreeView::moveCursor(), QCalendarView::moveCursor(), QColumnViewGrip::moveGrip(), QTabBar::moveTab(), QTableView::paintEvent(), QWellArray::paintEvent(), QMenu::popup(), QAccessibleItemView::rect(), QColumnView::resizeEvent(), QDialog::resizeEvent(), QHeaderView::resizeSection(), QExpandingLineEdit::resizeToContents(), QColumnView::scrollContentsBy(), QTableView::scrollContentsBy(), QTreeView::scrollContentsBy(), QGraphicsView::scrollContentsBy(), QTextEdit::scrollContentsBy(), QColumnView::scrollTo(), QDateTimeEdit::sectionText(), QDateTimeEdit::setDisplayFormat(), QBoxLayout::setGeometry(), QHeaderView::setOffset(), QTableView::setSelection(), QListView::setSelection(), QTreeView::setSelection(), QDialog::setSizeGripEnabled(), QMdiSubWindow::showSystemMenu(), QTableView::timerEvent(), QTreeView::timerEvent(), QTableView::updateGeometries(), QTreeView::visualRect(), and QTreeView::visualRegionForSelection().

428 { return layoutDirection() == Qt::RightToLeft; }
Qt::LayoutDirection layoutDirection() const

◆ isTopLevel()

bool QWidget::isTopLevel ( ) const
inline

Use isWindow() instead.

Definition at line 942 of file qwidget.h.

Referenced by QWindowsXPStyle::drawControl(), QSizeGrip::mouseMoveEvent(), setWindowSurface(), QCoreFuriCuri::timerEvent(), and windowSurface().

943 { return (windowType() & Qt::Window); }
Qt::WindowType windowType() const
Returns the window type of this widget.
Definition: qwidget.h:937

◆ isVisible()

bool QWidget::isVisible ( ) const
inline

Definition at line 1005 of file qwidget.h.

Referenced by QCompleterPrivate::_q_autoResizePopup(), QPrintDialogPrivate::_q_collapseOrExpandDialog(), QMdiAreaPrivate::_q_deactivateAllWindows(), QTextEditPrivate::_q_ensureVisible(), QFileDialogPrivate::_q_selectionChanged(), QAccessibleAbstractScrollArea::accessibleChildren(), QMenuBar::actionEvent(), QMenu::actionEvent(), QAccessibleMenu::actionText(), QAccessibleMenuBar::actionText(), QAccessibleComboBox::actionText(), QWidgetPrivate::activateChildLayoutsRecursively(), activateWindow(), QLayout::addChildWidget(), QMainWindow::addDockWidget(), QDialog::adjustPosition(), QApplication::alert(), QDockAreaLayoutInfo::apply(), QWorkspace::changeEvent(), QMdiSubWindow::changeEvent(), QMenu::changeEvent(), QAccessibleWidget::childAt(), QAccessibleItemRow::childAt(), QAccessibleTextEdit::childAt(), QAccessibleMainWindow::childAt(), QAccessibleTitleBar::childCount(), QSplitter::childEvent(), QWidgetPrivate::clipRect(), QWidgetPrivate::close_helper(), QApplication::closeAllWindows(), QDialog::closeEvent(), QTreeView::columnCountChanged(), QApplication::commitData(), QShortcutMap::correctWidgetContext(), QFileDialogPrivate::createNavServicesDialog(), QEgl::createSurface(), QAbstractItemView::currentChanged(), QAbstractItemView::dataChanged(), discardInvalidateBufferRequest(), discardSyncRequest(), QAccessibleMenu::doAction(), QAccessibleMenuBar::doAction(), QAccessibleMenuItem::doAction(), QMotifStyle::drawComplexControl(), QMotifStyle::drawControl(), QMotifStyle::drawPrimitive(), dumpRecursive(), effectiveState(), QSplitter::event(), QApplication::event(), event(), QWindowsStyle::eventFilter(), QMenuBar::eventFilter(), QMdiArea::eventFilter(), QComboBoxPrivateContainer::eventFilter(), QAxServerBase::eventFilter(), find_child(), QX11Data::findClientWindow(), findWindowThatShouldDisplayMenubar(), flipPoint(), QEventDispatcherMac::flush(), QWidgetPrivate::frameStrut(), QWidgetPrivate::getOpaqueChildren(), QApplicationPrivate::globalEventProcessor(), QWidgetPrivate::hide_sys(), QWorkspace::hideEvent(), QStatusBar::hideOrShow(), QMdiAreaPrivate::hideRubberBand(), QTreeView::indexRowSizeHint(), QSplitterPrivate::insertWidget(), QAxServerBase::internalActivate(), QWidgetPrivate::isOverlapped(), isServerProcess(), QToolTip::isVisible(), isVisibleTo(), QDialog::keyPressEvent(), QAbstractSpinBox::keyPressEvent(), make_widget_eventUPP(), make_win_eventUPP(), QWidgetBackingStore::markDirty(), QMdiSubWindow::maximizedButtonsWidget(), QMdiSubWindow::maximizedSystemMenuIconWidget(), QStatusBarPrivate::messageRect(), QMdiSubWindow::minimumSizeHint(), QListView::mouseMoveEvent(), QMenu::mouseMoveEvent(), QAccessibleTitleBar::navigate(), QStatusBar::paintEvent(), QGLOverlayWidget::paintGL(), parseGeometry(), QMainWindowLayout::plug(), QMenuPrivate::popupAction(), QWidgetPrivate::prepareToRender(), previousInFocusChain(), QLineControl::processKeyEvent(), q_createNativeChildrenAndSetParent(), QBBWindow::QBBWindow(), qstring_to_xtp(), qt_change_net_wm_state(), qt_event_activate_timer_callbk(), qt_mac_get_widget_rgn(), qt_mac_set_drawer_preferred_edge(), qt_mac_should_disable_menu(), qt_qpa_set_cursor(), qt_win_set_cursor(), qt_x11_recreateWidget(), QtWndProc(), QApplication::qwsProcessEvent(), QApplication::qwsSetCustomColors(), QMdiAreaPrivate::rearrange(), QAccessibleWidget::rect(), QAccessibleAbstractScrollArea::rect(), QAccessibleItemRow::rect(), QAccessibleItemView::rect(), QAccessibleTitleBar::rect(), removeInvisibleWidgetsFromList(), repaint(), QETWidget::repaintDecoration(), QLayoutPrivate::reparentChildWidgets(), QColumnView::resizeEvent(), QMdiSubWindow::resizeEvent(), QMdiAreaPrivate::resizeToMinimumTileSize(), QMdiSubWindowPrivate::restoreFocus(), QAbstractItemView::rowsInserted(), scroll(), QTextEdit::scrollToAnchor(), QAbstractItemView::selectionChanged(), QApplicationPrivate::sendSyntheticEnterLeave(), QGraphicsProxyWidgetPrivate::sendWidgetKeyEvent(), QGraphicsProxyWidgetPrivate::sendWidgetMouseEvent(), QApplication::setActiveWindow(), QAbstractItemView::setAlternatingRowColors(), QToolButton::setArrowType(), setAttribute(), QProgressDialog::setBar(), QProgressDialog::setCancelButton(), QProgressDialog::setCancelButtonText(), QMdiAreaPrivate::setChildActivationEnabled(), setContentsMargins(), setDisabledStyle(), QDockWidget::setFloating(), setForegroundRole(), QAbstractScrollArea::setHorizontalScrollBarPolicy(), QAbstractButton::setIconSize(), QProgressDialog::setLabel(), QProgressDialog::setLabelText(), QAbstractSpinBox::setLineEdit(), QComboBox::setLineEdit(), setMask(), QSplitter::setOrientation(), setParent(), QWidgetPrivate::setParent_sys(), QSplashScreen::setPixmap(), QDeclarativeView::setRootObject(), QGraphicsView::setScene(), QWellArray::setSelected(), QMenu::setSeparatorsCollapsible(), QStatusBar::setSizeGripEnabled(), QMenu::setTearOffEnabled(), QToolButton::setToolButtonStyle(), QTabWidget::setUpLayout(), QProgressBar::setValue(), QProgressDialog::setValue(), QAbstractScrollArea::setVerticalScrollBarPolicy(), QAbstractScrollArea::setViewport(), QDialog::setVisible(), setVisible(), QGraphicsProxyWidgetPrivate::setWidget_helper(), setWindowFlags(), QProgressDialog::showEvent(), QWorkspacePrivate::showMaximizeControls(), QErrorMessage::showMessage(), showMinimized(), QCompleterPrivate::showPopup(), QMdiSubWindow::showShaded(), QToolTip::showText(), QMacStyle::sizeFromContents(), QTableView::sizeHintForColumn(), QAccessibleMdiSubWindow::state(), QAccessibleTabBar::state(), QWidgetBackingStore::staticContents(), QWidgetPrivate::subtractOpaqueSiblings(), QDirectFBScreen::surfaceForWidget(), QWidgetBackingStore::sync(), QAbstractItemView::timerEvent(), QPlatformScreen::topLevelAt(), QStatusBarPrivate::tryToShowSizeGrip(), update(), QCalendarWidget::updateCell(), QCalendarWidget::updateCells(), QWidgetPrivate::updateGeometry_helper(), updateMicroFocus(), QGLContext::updatePaintDevice(), QComboBoxPrivateContainer::updateScrollers(), QMdiAreaPrivate::updateTabBarGeometry(), QApplication::x11ProcessEvent(), and ~QWidget().

bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041

◆ isVisibleTo()

bool QWidget::isVisibleTo ( QWidget ancestor) const

Returns true if this widget would become visible if ancestor is shown; otherwise returns 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() isVisible()

Definition at line 8371 of file qwidget.cpp.

Referenced by QGroupBoxPrivate::_q_fixFocus(), QWorkspace::addWindow(), QGraphicsProxyWidgetPrivate::findFocusChild(), QApplicationPrivate::focusNextPrevChild_helper(), QX11EmbedWidgetPrivate::getFocusWidget(), QMdiAreaPrivate::place(), QAbstractScrollAreaPrivate::replaceScrollBar(), and QMacStylePrivate::timerEvent().

8372 {
8373  if (!ancestor)
8374  return isVisible();
8375  const QWidget * w = this;
8376  while (!w->isHidden()
8377  && !w->isWindow()
8378  && w->parentWidget()
8379  && w->parentWidget() != ancestor)
8380  w = w->parentWidget();
8381  return !w->isHidden();
8382 }
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
bool isWindow() const
Returns true if the widget is an independent window, otherwise returns false.
Definition: qwidget.h:945
bool isVisible() const
Definition: qwidget.h:1005
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
bool isHidden() const
Returns true if the widget is hidden, otherwise returns false.
Definition: qwidget.h:1008

◆ isWindow()

bool QWidget::isWindow ( ) const
inline

Returns true if the widget is an independent window, otherwise returns false.

A window is a widget that isn't visually the child of any other widget and that usually has a frame and a window title.

A window 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 windows, even if a parent widget is specified in the constructor. This behavior is specified by the Qt::Window flag.

See also
window(), isModal(), parentWidget()

Definition at line 945 of file qwidget.h.

Referenced by QLayout::activate(), QWidgetPrivate::activateChildLayoutsRecursively(), activateWindow(), QDialogButtonBoxPrivate::addButton(), QMacStylePrivate::addWidget(), QWidgetAnimator::animate(), QApplicationPrivate::applyX11SpecificCommandLineArguments(), backgroundRole(), QWidgetBackingStore::beginPaint(), changeEvent(), QAccessibleWidget::childAt(), QAccessibleMainWindow::childAt(), QWidgetPrivate::childAtRecursiveHelper(), QSplitter::childEvent(), childWidgets(), QDesktopWidgetPrivate::cleanup(), QWidgetPrivate::clipRect(), QWidgetPrivate::clipToEffectiveMask(), QDialog::contextMenuEvent(), QShortcutMap::correctWidgetContext(), create(), QWidgetPrivate::createRecursively(), QWidgetPrivate::createWinId(), destroy(), QPushButtonPrivate::dialogParent(), QApplicationPrivate::dispatchEnterLeave(), do_size_hints(), QOleDropTarget::DragOver(), QWindowsMobileStyle::drawControl(), QWindowsXPStyle::drawControl(), QWindowsStyle::drawControl(), effectiveState(), QDockWidget::event(), QMacStyle::event(), QToolBar::event(), QDialogButtonBox::event(), event(), QWindowsStyle::eventFilter(), QStyledItemDelegate::eventFilter(), QItemDelegate::eventFilter(), extendedPseudoClass(), QGestureManager::filterEvent(), find_child(), flipPoint(), focusInEvent(), focusNextPrevChild(), focusOutEvent(), QGestureManager::getGestureTargets(), QWidgetPrivate::getOpaqueChildren(), QApplicationPrivate::giveFocusAccordingToFocusPolicy(), QApplicationPrivate::globalEventProcessor(), handle_xdnd_position(), QWidgetPrivate::hide_helper(), QWidgetPrivate::hideChildren(), QDesktopWidgetPrivate::init(), QStyleOption::init(), QGLWidgetPrivate::init(), QApplicationPrivate::isAlien(), isAncestorOf(), QWidgetPrivate::isBackgroundInherited(), isEnabledTo(), QDockWidget::isFloating(), QToolBar::isFloating(), QWindowsXPStylePrivate::isItemViewDelegateLineEdit(), QWidgetPrivate::isOverlapped(), isServerProcess(), isVisibleTo(), lower(), QMenuBarPrivate::macCreateMenuBar(), make_widget_eventUPP(), make_win_eventUPP(), QWidgetBackingStore::markDirtyOnScreen(), menuBarHeightForWidth(), QSizeGrip::mouseMoveEvent(), QWidgetResizeHandler::mouseMoveEvent(), QSizeGrip::mousePressEvent(), move(), QApplication::notify(), QToolBar::paintEvent(), QWidgetPrivate::paintSiblingsRecursive(), QCommonStyle::pixelMetric(), QPlastiqueStyle::pixelMetric(), QMacStyle::pixelMetric(), QWidgetPrivate::pointToRect(), QWidgetPrivate::propagatePaletteChange(), q_createNativeChildrenAndSetParent(), QPlaceHolderItem::QPlaceHolderItem(), QRubberBand::QRubberBand(), qt_cleanup(), qt_grab_cursor(), qt_insert_sip(), qt_mac_is_metal(), qt_mac_posInWindow(), qt_mac_post_retranslateAppMenu(), qt_mac_unregister_widget(), qt_mac_update_widget_position(), qt_mac_updateCursorWithWidgetUnderMouse(), qt_net_update_user_time(), qt_nograb(), qt_sizegrip_topLevelWidget(), qt_try_modal(), qt_x11_enforce_cursor(), qt_x11_wait_for_window_manager(), QtWndProc(), raise(), QETWidget::repaintDecoration(), QMdiAreaPrivate::resizeToMinimumTileSize(), QToolBarAreaLayout::saveState(), QDesktopWidget::screenNumber(), QWidgetPrivate::scroll_sys(), QWidgetPrivate::scrollChildren(), sendResizeEvents(), QApplicationPrivate::sendSyntheticEnterLeave(), setAttribute(), setBaseSize(), QWSWindowSurface::setClipRegion(), setDisabled(), setDisabledStyle(), QToolBarLayout::setExpanded(), setFixedSize(), setFocus(), QApplication::setFont(), QWSWindowSurface::setGeometry(), setGeometry(), setLayout(), QWidgetPrivate::setLayoutDirection_helper(), QWidgetPrivate::setLocale_helper(), setMask(), setMaximumSize(), setMinimumSize(), QWidgetPrivate::setModal_sys(), QApplicationPrivate::setPalette_helper(), setParent(), QWidgetPrivate::setParent_sys(), setSizeIncrement(), setSizePolicy(), QDockWidget::setTitleBarWidget(), QMainWindow::setUnifiedTitleAndToolBarOnMac(), QWidgetPrivate::setUpdatesEnabled_helper(), QDialog::setVisible(), setVisible(), QFocusFrame::setWidget(), QGraphicsProxyWidgetPrivate::setWidget_helper(), QWSDisplay::setWindowCaption(), QApplication::setWindowIcon(), QWidgetPrivate::setWindowIcon_helper(), setWindowOpacity(), QWidgetPrivate::showChildren(), QSoftKeyManager::softkeySource(), stackUnder(), QWidgetPrivate::stackUnder_sys(), QWindowsXPStyle::standardIconImplementation(), QWindowsXPStyle::standardPixmap(), QAccessibleWidget::state(), QWindowsStyle::styleHint(), QGtkStyle::styleHint(), QMacStyle::styleHint(), QWidgetPrivate::subtractOpaqueSiblings(), IsWindowAndNotDrawerOrSheetTest::test(), testAttribute_helper(), QApplication::topLevelWidgets(), QAxServerBase::TranslateAcceleratorW(), QETWidget::translateMouseEvent(), QMainWindowLayout::unplug(), unsetCursor(), unsetLayoutDirection(), QAccessible::updateAccessibility(), QWidgetPrivate::updateFont(), QDirectFBWindowSurface::updateIsOpaque(), QSizeGripPrivate::updateMacSizer(), QGLContext::updatePaintDevice(), QGraphicsProxyWidgetPrivate::updateProxyGeometryFromWidget(), QDesktopWidgetPrivate::updateScreenList(), QStyleSheetStyle::updateStyleSheetFont(), QLayout::widgetEvent(), window(), QWSWindowSurface::winId(), QApplication::x11ProcessEvent(), and ~QWidget().

946 { return (windowType() & Qt::Window); }
Qt::WindowType windowType() const
Returns the window type of this widget.
Definition: qwidget.h:937

◆ isWindowModified()

bool QWidget::isWindowModified ( ) const

Definition at line 11554 of file qwidget.cpp.

Referenced by QMacStyle::drawComplexControl(), QMdiSubWindow::event(), QWorkspaceChild::eventFilter(), qt_setWindowTitle_helperHelper(), QMdiSubWindow::setWidget(), and tabTextFor().

11555 {
11557 }
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041

◆ keyboardGrabber()

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(), mouseGrabber()

Definition at line 3358 of file qwidget_mac.mm.

Referenced by isServerProcess(), qstring_to_xtp(), qt_grab_cursor(), QtWndProc(), QApplication::qwsProcessEvent(), QTest::sendKeyEvent(), and QApplication::x11ProcessEvent().

3359 {
3360  return mac_keyboard_grabber;
3361 }
QWidget * mac_keyboard_grabber
Definition: qwidget_mac.mm:157

◆ keyPressEvent()

void QWidget::keyPressEvent ( QKeyEvent event)
protectedvirtual

This event handler, for event event, 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 call the base class implementation if you do not act upon the key.

The default implementation closes popup widgets if the user presses Esc. Otherwise the event is ignored, so that the widget's parent can interpret it.

Note that QKeyEvent starts with isAccepted() == true, so you do not need to call QKeyEvent::accept() - just do not call the base class implementation if you act upon the key.

See also
keyReleaseEvent(), setFocusPolicy(), focusInEvent(), focusOutEvent(), event(), QKeyEvent, {Tetrix Example}

Reimplemented in QCalendarView, QFileDialogTreeView, QFileDialogListView, QFileDialogLineEdit, QAbstractItemView, QMessageBox, QTextEdit, QGraphicsView, QComboBox, QPlainTextEdit, QLineEdit, QTreeView, QTabBar, QDateTimeEdit, QWhatsThat, QMenu, QTabWidget, QCalendarWidget, QWellArray, QAbstractSlider, QInputDialogDoubleSpinBox, QLabel, QAbstractSpinBox, QAbstractButton, QMenuBar, QMdiSubWindow, QAbstractScrollArea, QDialog, QTextBrowser, QScriptNewBreakpointWidget, QInputDialogSpinBox, QPushButton, QScriptDebuggerConsoleWidget, QScriptDebuggerCodeFinderWidget, and QScriptBreakpointsWidget.

Definition at line 9375 of file qwidget.cpp.

Referenced by QComboBox::addItems(), event(), QCalendarWidget::isNavigationBarVisible(), QScriptDebuggerCodeFinderWidget::keyPressEvent(), QScriptDebuggerConsoleWidget::keyPressEvent(), QScriptNewBreakpointWidget::keyPressEvent(), QCalendarWidget::keyPressEvent(), and setShown().

9376 {
9377  if ((windowType() == Qt::Popup) && event->key() == Qt::Key_Escape) {
9378  event->accept();
9379  close();
9380  } else {
9381  event->ignore();
9382  }
9383 }
int key() const
Returns the code of the key that was pressed or released.
Definition: qevent.h:231
Qt::WindowType windowType() const
Returns the window type of this widget.
Definition: qwidget.h:937
bool close()
Closes this widget.
Definition: qwidget.cpp:8305

◆ keyReleaseEvent()

void QWidget::keyReleaseEvent ( QKeyEvent event)
protectedvirtual

This event handler, for event event, can be reimplemented in a subclass to receive key release events for the widget.

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 call the base class implementation if you do not act upon the key.

The default implementation ignores the event, so that the widget's parent can interpret it.

Note that QKeyEvent starts with isAccepted() == true, so you do not need to call QKeyEvent::accept() - just do not call the base class implementation if you act upon the key.

See also
keyPressEvent(), QKeyEvent::ignore(), setFocusPolicy(), focusInEvent(), focusOutEvent(), event(), QKeyEvent

Reimplemented in QTextEdit, QGraphicsView, QComboBox, QPlainTextEdit, QAbstractSpinBox, and QAbstractButton.

Definition at line 9407 of file qwidget.cpp.

Referenced by QComboBox::addItems(), event(), QGraphicsView::keyReleaseEvent(), setShown(), and QPlainTextEdit::toPlainText().

9408 {
9409  event->ignore();
9410 }

◆ languageChange()

void QWidget::languageChange ( )
protectedvirtual

Definition at line 12005 of file qwidget.cpp.

Referenced by event().

12005 { } // compat

◆ layout()

QLayout * QWidget::layout ( ) const

Returns the layout manager that is installed on this widget, or 0 if no layout manager is installed.

The layout manager sets the geometry of the widget's children that have been added to the layout.

See also
setLayout(), sizePolicy(), {Layout Management}

Definition at line 10073 of file qwidget.cpp.

Referenced by QToolBoxPrivate::_q_widgetDestroyed(), QLayout::addChildWidget(), QAbstractScrollAreaScrollBarContainer::addWidget(), QMainWindowPrivate::adjustCursor(), QWidgetPrivate::adjustedSize(), QMainWindow::centralWidget(), QDockWidget::changeEvent(), QLayout::closestAcceptableSize(), QLayoutPrivate::createSpacerItem(), QStackedWidget::currentWidget(), dockedGeometry(), QDockWidgetItem::dockWidgetLayout(), QAccessibleTitleBar::dockWidgetLayout(), QDockWidget::event(), QTreeViewPrivate::expand(), QToolBarAreaLayoutLine::fitLayout(), QWidgetPrivate::hasHeightForWidth(), heightForWidth(), QToolBar::initStyleOption(), QMainWindowLayout::insertIntoMacToolbar(), QTreeViewPrivate::layout(), QMessageBoxPrivate::layoutMinimumWidth(), QMainWindowPrivate::mainWindowLayout(), QMainWindow::menuBar(), QMainWindow::menuWidget(), QMdiSubWindow::minimumSizeHint(), QApplicationPrivate::notify_helper(), QTextEditPrivate::paint(), QDockWidget::paintEvent(), QLabel::paintEvent(), QPlainTextEdit::paintEvent(), QAbstractScrollAreaScrollBarContainer::QAbstractScrollAreaScrollBarContainer(), QBalloonTip::QBalloonTip(), QComboBoxPrivateContainer::QComboBoxPrivateContainer(), QLayout::QLayout(), QMdiSubWindow::QMdiSubWindow(), QMessageBoxDetailsText::QMessageBoxDetailsText(), qt_mainwindow_layout(), QtWndProc(), QWizardHeader::QWizardHeader(), QAccessibleDockWidget::rect(), QAccessibleTitleBar::rect(), QToolBoxPrivate::relayout(), QTextEditPrivate::relayoutDocument(), QMainWindowLayout::removeFromMacToolbar(), QX11EmbedWidget::resizeEvent(), QAbstractScrollAreaScrollBarContainer::scrollBarLayoutIndex(), QMainWindowPrivate::separatorCursor(), QWizard::setButtonLayout(), QCalendarPopup::setCalendarWidget(), QMessageBox::setDetailedText(), QDockWidget::setFeatures(), QRasterWindowSurface::setGeometry(), QToolBar::setIconSize(), QMessageBox::setInformativeText(), QComboBoxPrivateContainer::setItemView(), setLayout(), QMainWindow::setMenuBar(), QDeclarativeView::setRootObject(), QDockWidget::setTitleBarWidget(), QWizardHeader::setup(), setVisible(), QDockWidget::setWidget(), QMdiSubWindow::setWidget(), QWidgetPrivate::show_recursive(), QMdiSubWindowPrivate::showButtonsInMenuBar(), QDialog::showExtension(), showFullScreen(), showMaximized(), showNormal(), QComboBox::showPopup(), QMainWindow::statusBar(), QCommonStyle::subElementRect(), takeLayout(), QDockWidget::titleBarWidget(), QMenuBarPrivate::updateCornerWidgetToolBar(), QWidgetPrivate::updateGeometry_helper(), QWizardPrivate::updateLayout(), QScrollAreaPrivate::updateScrollBars(), QMessageBoxPrivate::updateSize(), QComboBoxPrivateContainer::updateTopBottomMargin(), QStackedWidget::widget(), QDockWidget::widget(), and QAbstractScrollAreaScrollBarContainer::widgets().

10074 {
10075  return d_func()->layout;
10076 }

◆ layoutDirection()

Qt::LayoutDirection QWidget::layoutDirection ( ) const

◆ leaveEvent()

void QWidget::leaveEvent ( QEvent event)
protectedvirtual

This event handler can be reimplemented in a subclass to receive widget leave events which are passed in the event parameter.

A leave event is sent to the widget when the mouse cursor leaves the widget.

See also
enterEvent(), mouseMoveEvent(), event()

Reimplemented in QWorkspaceChild, QMdi::ControllerWidget, QWorkspaceTitleBar, CloseButton, QComboBoxPrivateContainer, QMenu, QComboBoxPrivateScroller, QMenuBar, QDockWidgetTitleButton, QMdiSubWindow, QToolButton, QMDIControl, and QVistaBackButton.

Definition at line 9491 of file qwidget.cpp.

Referenced by event(), QMdi::ControllerWidget::hasVisibleControls(), QVistaBackButton::leaveEvent(), QToolButton::leaveEvent(), QDockWidgetTitleButton::leaveEvent(), CloseButton::leaveEvent(), and setShown().

9492 {
9493 }

◆ locale()

QLocale QWidget::locale ( ) const

◆ lower

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.

See also
raise(), stackUnder()

Definition at line 11939 of file qwidget.cpp.

Referenced by QMdiAreaPrivate::_q_deactivateAllWindows(), QDockAreaLayoutInfo::apply(), QWorkspacePrivate::insertIcon(), QStackedLayout::insertWidget(), QSplitterPrivate::insertWidget(), QAlphaWidget::render(), QRollEffect::scroll(), and QTabBar::setTabButton().

11940 {
11941  Q_D(QWidget);
11942  if (!isWindow()) {
11943  QWidget *p = parentWidget();
11944  const int parentChildCount = p->d_func()->children.size();
11945  if (parentChildCount < 2)
11946  return;
11947  const int from = p->d_func()->children.indexOf(this);
11948  Q_ASSERT(from >= 0);
11949  // Do nothing if the widget is already in correct stacking order _and_ created.
11950  if (from != 0)
11951  p->d_func()->children.move(from, 0);
11953  create();
11954  else if (from == 0)
11955  return;
11956  }
11958  d->lower_sys();
11959 
11961  QApplication::sendEvent(this, &e);
11962 }
double d
Definition: qnumeric_p.h:62
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
bool isWindow() const
Returns true if the widget is an independent window, otherwise returns false.
Definition: qwidget.h:945
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define Q_D(Class)
Definition: qglobal.h:2482
void move(int from, int to)
Moves the item at index position from to index position to.
Definition: qlist.h:628
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
void create(WId=0, bool initializeWindow=true, bool destroyOldWindow=true)
Creates a new widget window if window is 0, otherwise sets the widget&#39;s window to window...
Definition: qwidget.cpp:1454
int indexOf(const T &t, int from=0) const
Returns the index position of the first occurrence of value in the list, searching forward from index...
Definition: qlist.h:847
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
const QObjectList & children() const
Returns a list of child objects.
Definition: qobject.h:197
The QEvent class is the base class of all event classes.
Definition: qcoreevent.h:56

◆ macCGHandle()

Qt::HANDLE QWidget::macCGHandle ( ) const

Returns the CoreGraphics handle of the widget.

Use of this function is not portable. This function will return 0 if no painter context can be established, or if the handle could not be created.

Warning
This function is only available on Mac OS X.

Definition at line 2735 of file qwidget_mac.mm.

2736 {
2737  return handle();
2738 }

◆ macEvent()

bool QWidget::macEvent ( EventHandlerCallRef  caller,
EventRef  event 
)
protectedvirtual

This special event handler can be reimplemented in a subclass to receive native Macintosh events.

The parameters are a bit different depending if Qt is build against Carbon or Cocoa. In Carbon, caller and event are the corresponding EventHandlerCallRef and EventRef that correspond to the Carbon event handlers that are installed. In Cocoa, caller is always 0 and the EventRef is the EventRef generated from the NSEvent.

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.
This function was not called inside of Qt until Qt 4.4. If you need compatibility with earlier versions of Qt, consider QApplication::macEventFilter() instead.
See also
QApplication::macEventFilter()

Definition at line 9918 of file qwidget.cpp.

Referenced by QApplicationPrivate::globalEventProcessor(), make_widget_eventUPP(), qt_mac_sendMacEventToWidget(), and setShown().

9919 {
9920  return false;
9921 }

◆ macQDHandle()

Qt::HANDLE QWidget::macQDHandle ( ) const

Returns the QuickDraw handle of the widget.

Use of this function is not portable. This function will return 0 if QuickDraw is not supported, or if the handle could not be created.

Warning
This function is only available on Mac OS X.

Definition at line 2718 of file qwidget_mac.mm.

2719 {
2720 #ifndef QT_MAC_USE_COCOA
2721  return d_func()->qd_hd;
2722 #else
2723  return 0;
2724 #endif
2725 }

◆ mapFrom()

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() underMouse()

Definition at line 4433 of file qwidget.cpp.

Referenced by QMainWindow::contextMenuEvent(), QX11Data::motifdndHandle(), qt_cleanup(), and QApplicationPrivate::sendSyntheticEnterLeave().

4434 {
4435  QPoint p(pos);
4436  if (parent) {
4437  const QWidget * w = this;
4438  while (w != parent) {
4439  Q_ASSERT_X(w, "QWidget::mapFrom(QWidget *parent, const QPoint &pos)",
4440  "parent must be in parent hierarchy");
4441 
4442  p = w->mapFromParent(p);
4443  w = w->parentWidget();
4444  }
4445  }
4446  return p;
4447 }
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_ASSERT_X(cond, where, what)
Definition: qglobal.h:1837
QPoint mapFromParent(const QPoint &) const
Translates the parent widget coordinate pos to widget coordinates.
Definition: qwidget.cpp:4473
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53

◆ mapFromGlobal()

QPoint QWidget::mapFromGlobal ( const QPoint pos) const

Translates the global screen coordinate pos to widget coordinates.

See also
mapToGlobal() mapFrom() mapFromParent()

Definition at line 3135 of file qwidget_mac.mm.

Referenced by axc_FilterProc(), QGraphicsViewPrivate::centerView(), QAccessibleWidget::childAt(), QAccessibleTable2::childAt(), QAccessibleTextEdit::childAt(), QAccessibleTree::childAt(), QAccessibleStackedWidget::childAt(), QAccessibleMainWindow::childAt(), QApplicationPrivate::dispatchEnterLeave(), QWidgetResizeHandler::doMove(), QWidgetResizeHandler::doResize(), QOleDropTarget::DragOver(), QOleDropTarget::Drop(), QDockWidget::event(), QToolBar::event(), QWidgetResizeHandler::eventFilter(), QMdiSubWindow::eventFilter(), find_child(), flipPoint(), QGraphicsScenePrivate::gestureEventHandler(), QApplicationPrivate::globalEventProcessor(), QAbstractItemView::horizontalScrollbarValueChanged(), QMainWindowLayout::hover(), QMenu::internalDelayedPopup(), isServerProcess(), QGraphicsItem::isUnderMouse(), QGraphicsScenePrivate::itemsAtPosition(), QMdiSubWindow::keyPressEvent(), QGraphicsScenePrivate::leaveScene(), mapFromGlobal(), QWidgetPrivate::mapFromGlobal(), QGestureEvent::mapToGraphicsScene(), QX11Data::motifdndHandle(), QWidgetResizeHandler::mouseMoveEvent(), QTipLabel::mouseMoveEvent(), QSplitterHandle::mouseMoveEvent(), QWorkspaceTitleBar::mouseMoveEvent(), QGraphicsItem::mouseMoveEvent(), QComboBoxPrivateContainer::mousePressEvent(), QSplitterHandle::mouseReleaseEvent(), QApplication::notify(), QAccessibleTextWidget::offsetAtPoint(), QAccessibleLineEdit::offsetAtPoint(), QWorkspaceTitleBar::paintEvent(), QApplicationPrivate::pickMouseReceiver(), q_createNativeChildrenAndSetParent(), qt_cleanup(), qt_keyrelease_scanner(), qt_mac_update_widget_position(), qt_mac_updateParentUnderAlienWidget(), qt_try_modal(), QtWndProc(), QOleDropTarget::sendDragEnterEvent(), QDeclarativeTextInputPrivate::sendMouseEventToInputContext(), QApplicationPrivate::sendSyntheticEnterLeave(), QGraphicsItem::setCursor(), QCursor::setPos(), QToolTip::showText(), QApplication::topLevelAt(), QETWidget::translateMouseEvent(), QApplicationPrivate::translateRawTouchEvent(), QETWidget::translateTabletEvent(), QETWidget::translateWheelEvent(), QETWidget::translateXinputEvent(), QGraphicsItem::unsetCursor(), QWinInputContext::update(), QGraphicsProxyWidgetPrivate::updateProxyGeometryFromWidget(), QApplicationPrivate::updateTouchPointsForWidget(), QAbstractItemView::verticalScrollbarValueChanged(), and QApplication::widgetAt().

3136 {
3137  Q_D(const QWidget);
3138  if (!internalWinId()) {
3139  QPoint p = isWindow() ? pos : parentWidget()->mapFromGlobal(pos);
3140  return p - data->crect.topLeft();
3141  }
3142 #ifndef QT_MAC_USE_COCOA
3143  Rect win_rect;
3144  GetWindowBounds(qt_mac_window_for(this), kWindowStructureRgn, &win_rect);
3145  HIPoint hi_pos = CGPointMake(pos.x()-win_rect.left, pos.y()-win_rect.top);
3146  HIViewConvertPoint(&hi_pos, 0, qt_mac_nativeview_for(this));
3147  return d->mapFromWS(QPoint((int)hi_pos.x, (int)hi_pos.y));
3148 #else
3149  NSRect win_rect = [qt_mac_window_for(this) frame];
3150  // The Window point is in "Cocoa coordinates," but the view is in "Qt coordinates"
3151  // so make sure to keep them in sync.
3152  NSPoint hi_pos = NSMakePoint(pos.x()-win_rect.origin.x,
3153  flipYCoordinate(pos.y())-win_rect.origin.y);
3154  hi_pos = [qt_mac_nativeview_for(this) convertPoint:hi_pos fromView:0];
3155  return d->mapFromWS(QPoint(qRound(hi_pos.x), qRound(hi_pos.y)));
3156 #endif
3157 }
QPoint pos() const
double d
Definition: qnumeric_p.h:62
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
int y() const
QRect crect
Definition: qwidget.h:131
int flipYCoordinate(int y)
bool isWindow() const
Returns true if the widget is an independent window, otherwise returns false.
Definition: qwidget.h:945
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
friend OSWindowRef qt_mac_window_for(const QWidget *w)
Definition: qwidget_mac.mm:484
#define Q_D(Class)
Definition: qglobal.h:2482
QWidgetData * data
Definition: qwidget.h:815
friend OSViewRef qt_mac_nativeview_for(const QWidget *w)
Definition: qwidget_mac.mm:419
int x() const
struct CGPoint NSPoint
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
WId internalWinId() const
Returns the window system identifier of the widget, or 0 if the widget is not created yet...
Definition: qwidget.h:244
int y() const
Returns the y coordinate of this point.
Definition: qpoint.h:131
QPoint mapFromGlobal(const QPoint &) const
Translates the global screen coordinate pos to widget coordinates.
return(isPopup||isToolTip)
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128
Q_DECL_CONSTEXPR int qRound(qreal d)
Definition: qglobal.h:1203
QPoint topLeft() const
Returns the position of the rectangle&#39;s top-left corner.
Definition: qrect.h:288

◆ 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() underMouse()

Definition at line 4473 of file qwidget.cpp.

Referenced by find_child(), mapFrom(), parseGeometry(), and QApplication::qwsProcessEvent().

4474 {
4475  return pos - data->crect.topLeft();
4476 }
QRect crect
Definition: qwidget.h:131
QWidgetData * data
Definition: qwidget.h:815
QPoint topLeft() const
Returns the position of the rectangle&#39;s top-left corner.
Definition: qrect.h:288

◆ mapTo()

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() underMouse()

Definition at line 4409 of file qwidget.cpp.

Referenced by QX11PaintEngine::begin(), QPainter::begin(), QWidgetBackingStore::beginPaint(), QWidgetBackingStore::bltRect(), QGLWindowSurface::buffer(), QAccessibleTable2::childAt(), QAccessibleTree::childAt(), QWidgetBackingStore::dirtyRegion(), do_size_hints(), QWindowsVistaStyle::drawComplexControl(), QScrollArea::ensureWidgetVisible(), QCalendarWidget::eventFilter(), QX11GLWindowSurface::grabWidget(), QX11WindowSurface::grabWidget(), QWidgetPrivate::isBackgroundInherited(), QWidgetBackingStore::markDirty(), QWidgetBackingStore::markDirtyOnScreen(), QWidgetPrivate::moveRect(), QWindowSurface::offset(), qt_flush(), qt_grab_cursor(), qt_mac_update_widget_position(), QAccessibleItemRow::rect(), QAccessibleTable2Cell::rect(), QWidgetBackingStore::showYellowThing(), QWidgetBackingStore::staticContents(), QGraphicsProxyWidget::subWidgetRect(), QDirectFBWindowSurface::surfaceForWidget(), QDirectFBScreen::surfaceForWidget(), QWidgetBackingStore::sync(), QWSInputContext::translateIMQueryEvent(), QWidgetBackingStore::unflushPaint(), QXIMInputContext::update(), updateRedirectedToGraphicsProxyWidget(), QFocusFramePrivate::updateSize(), visibleRegion(), and QApplication::x11ProcessEvent().

4410 {
4411  QPoint p = pos;
4412  if (parent) {
4413  const QWidget * w = this;
4414  while (w != parent) {
4415  Q_ASSERT_X(w, "QWidget::mapTo(QWidget *parent, const QPoint &pos)",
4416  "parent must be in parent hierarchy");
4417  p = w->mapToParent(p);
4418  w = w->parentWidget();
4419  }
4420  }
4421  return p;
4422 }
QPoint pos() const
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_ASSERT_X(cond, where, what)
Definition: qglobal.h:1837
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
QPoint mapToParent(const QPoint &) const
Translates the widget coordinate pos to a coordinate in the parent widget.
Definition: qwidget.cpp:4459

◆ mapToGlobal()

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() mapToParent()

Definition at line 3108 of file qwidget_mac.mm.

Referenced by QFileDialogPrivate::_q_showContextMenu(), QDialog::adjustPosition(), QOnScreenRasterPaintEngine::begin(), QAccessibleWidget::childAt(), QAccessibleAbstractScrollArea::childAt(), QAccessibleComboBox::childAt(), QAccessibleMainWindow::childAt(), QDesktopWidgetPrivate::cleanup(), QGraphicsProxyWidget::contextMenuEvent(), QDialog::contextMenuEvent(), QAbstractSpinBox::contextMenuEvent(), QOnScreenRasterPaintEngine::coordinateOffset(), PvrEglScreenSurfaceFunctions::createNativeWindow(), event(), QWorkspace::eventFilter(), QCompleter::eventFilter(), QComboBoxPrivateContainer::eventFilter(), QWSWindowSurface::flush(), QWSYellowSurface::flush(), QWidgetPrivate::frameStrut(), QMacInputContext::globalEventProcessor(), QPixmap::grabWindow(), handle_xdnd_position(), QAccessibleDisplay::imagePosition(), QDesktopWidgetPrivate::init(), QMenu::internalDelayedPopup(), isServerProcess(), QMdiSubWindow::keyPressEvent(), QWidgetPrivate::mapFromGlobal(), mapToGlobal(), QTest::QTouchEventSequence::mapToScreen(), QTest::mouseEvent(), QCalendarPopup::mousePressEvent(), QComboBox::mousePressEvent(), QAbstractButtonPrivate::moveFocus(), QMainWindowLayout::plug(), QMenu::popup(), q_createNativeChildrenAndSetParent(), qt_keyrelease_scanner(), qt_mac_update_intersected_gl_widgets(), qt_mac_update_widget_position(), qt_mac_updateParentUnderAlienWidget(), QtWndProc(), QAccessibleMenu::rect(), QAccessibleWidget::rect(), QAccessibleTable2::rect(), QAccessibleAbstractSpinBox::rect(), QAccessibleAbstractScrollArea::rect(), QAccessibleMenuBar::rect(), QAccessibleToolButton::rect(), QAccessibleHeader::rect(), QAccessibleMenuItem::rect(), QAccessibleDoubleSpinBox::rect(), QAccessibleItemRow::rect(), QAccessibleTextEdit::rect(), QAccessibleScrollBar::rect(), QAccessibleItemView::rect(), QAccessibleTable2Cell::rect(), QAccessibleSlider::rect(), QAccessibleDial::rect(), QAccessibleTabBar::rect(), QAccessibleTable2HeaderCell::rect(), QAccessibleMdiSubWindow::rect(), QAccessibleComboBox::rect(), QAccessibleCalendarWidget::rect(), QAccessibleTitleBar::rect(), QDesktopWidget::screenNumber(), QGraphicsProxyWidgetPrivate::sendWidgetMouseEvent(), PvrEglWindowSurface::setDirectRegion(), QDockWidget::setFloating(), QSidebar::showContextMenu(), QCompleterPrivate::showPopup(), QComboBox::showPopup(), QMdiSubWindow::showSystemMenu(), QAccessibleTable2Cell::state(), QETWidget::translateMouseEvent(), QETWidget::translateRegionEvent(), QWinInputContext::update(), and QDesktopWidgetPrivate::updateScreenList().

3109 {
3110  Q_D(const QWidget);
3111  if (!internalWinId()) {
3112  QPoint p = pos + data->crect.topLeft();
3113  return isWindow() ? p : parentWidget()->mapToGlobal(p);
3114  }
3115 #ifndef QT_MAC_USE_COCOA
3116  QPoint tmp = d->mapToWS(pos);
3117  HIPoint hi_pos = CGPointMake(tmp.x(), tmp.y());
3118  HIViewConvertPoint(&hi_pos, qt_mac_nativeview_for(this), 0);
3119  Rect win_rect;
3120  GetWindowBounds(qt_mac_window_for(this), kWindowStructureRgn, &win_rect);
3121  return QPoint((int)hi_pos.x+win_rect.left, (int)hi_pos.y+win_rect.top);
3122 #else
3123  QPoint tmp = d->mapToWS(pos);
3124  NSPoint hi_pos = NSMakePoint(tmp.x(), tmp.y());
3125  hi_pos = [qt_mac_nativeview_for(this) convertPoint:hi_pos toView:nil];
3126  NSRect win_rect = [qt_mac_window_for(this) frame];
3127  hi_pos.x += win_rect.origin.x;
3128  hi_pos.y += win_rect.origin.y;
3129  // If we aren't the desktop we need to flip, if you flip the desktop on itself, you get the other problem.
3130  return ((window()->windowFlags() & Qt::Desktop) == Qt::Desktop) ? QPointF(hi_pos.x, hi_pos.y).toPoint()
3131  : flipPoint(hi_pos).toPoint();
3132 #endif
3133 }
double d
Definition: qnumeric_p.h:62
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
int y() const
QRect crect
Definition: qwidget.h:131
bool isWindow() const
Returns true if the widget is an independent window, otherwise returns false.
Definition: qwidget.h:945
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
friend OSWindowRef qt_mac_window_for(const QWidget *w)
Definition: qwidget_mac.mm:484
QPointF flipPoint(const NSPoint &p)
#define Q_D(Class)
Definition: qglobal.h:2482
QWidgetData * data
Definition: qwidget.h:815
friend OSViewRef qt_mac_nativeview_for(const QWidget *w)
Definition: qwidget_mac.mm:419
int x() const
struct CGPoint NSPoint
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
Definition: qnamespace.h:54
WId internalWinId() const
Returns the window system identifier of the widget, or 0 if the widget is not created yet...
Definition: qwidget.h:244
int y() const
Returns the y coordinate of this point.
Definition: qpoint.h:131
QWidget * window() const
Returns the window for this widget, i.e.
Definition: qwidget.cpp:4492
return(isPopup||isToolTip)
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128
Qt::WindowFlags windowFlags() const
Window flags are a combination of a type (e.
Definition: qwidget.h:939
QPoint mapToGlobal(const QPoint &) const
Translates the widget coordinate pos to global screen coordinates.
QPoint topLeft() const
Returns the position of the rectangle&#39;s top-left corner.
Definition: qrect.h:288

◆ mapToParent()

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() underMouse()

Definition at line 4459 of file qwidget.cpp.

Referenced by QVistaHelper::drawTitleBar(), handle_xdnd_position(), mapTo(), QMdiSubWindow::mouseMoveEvent(), QWorkspaceTitleBar::mouseMoveEvent(), QMdiSubWindow::mousePressEvent(), QWorkspaceTitleBar::mousePressEvent(), QApplication::notify(), and QVistaBackButton::paintEvent().

4460 {
4461  return pos + data->crect.topLeft();
4462 }
QRect crect
Definition: qwidget.h:131
QWidgetData * data
Definition: qwidget.h:815
QPoint topLeft() const
Returns the position of the rectangle&#39;s top-left corner.
Definition: qrect.h:288

◆ mask()

QRegion QWidget::mask ( ) const

Returns the mask currently set on a widget.

If no mask is set the return value will be an empty region.

See also
setMask(), clearMask(), QRegion::isEmpty(), {Shaped Clock Example}

Definition at line 10058 of file qwidget.cpp.

Referenced by QSystemTrayIconSys::getSysTrayVisualInfo(), make_widget_eventUPP(), QWSMemorySurface::painterOffset(), QGraphicsView::paintEvent(), parseGeometry(), QWidgetPrivate::propagatePaletteChange(), qCanAllocColors(), qt_mac_unregister_widget(), setDisabled(), QWSWindowSurface::setGeometry(), QWSLocalMemSurface::setGeometry(), QShapedPixmapWidget::setPixmap(), showNewMessageBox(), QWidgetPrivate::subtractOpaqueSiblings(), QApplication::topLevelAt(), QRubberBandPrivate::updateMask(), QWorkspaceChild::updateMask(), QApplication::widgetAt(), and QVGEGLWindowSurfacePrivate::windowSurfaceSize().

10059 {
10060  Q_D(const QWidget);
10061  return d->extra ? d->extra->mask : QRegion();
10062 }
double d
Definition: qnumeric_p.h:62
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_D(Class)
Definition: qglobal.h:2482
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68

◆ maximumHeight()

int QWidget::maximumHeight ( ) const

◆ maximumSize()

QSize QWidget::maximumSize ( ) const

◆ maximumWidth()

int QWidget::maximumWidth ( ) const

◆ metric()

int QWidget::metric ( PaintDeviceMetric  m) const
protectedvirtual

Internal implementation of the virtual QPaintDevice::metric() function.

m is the metric to get.

Reimplemented from QPaintDevice.

Definition at line 4908 of file qwidget_mac.mm.

Referenced by do_size_hints(), effectiveState(), qt_grab_cursor(), QMainWindow::setIconSize(), QToolBar::setIconSize(), and setShown().

4909 {
4910  switch(m) {
4911  case PdmHeightMM:
4912  return qRound(metric(PdmHeight) * 25.4 / qreal(metric(PdmDpiY)));
4913  case PdmWidthMM:
4914  return qRound(metric(PdmWidth) * 25.4 / qreal(metric(PdmDpiX)));
4915  case PdmHeight:
4916  case PdmWidth:
4917 #ifndef QT_MAC_USE_COCOA
4918  { HIRect rect;
4919  HIViewGetFrame(qt_mac_nativeview_for(this), &rect);
4920  if(m == PdmWidth)
4921  return (int)rect.size.width;
4922  return (int)rect.size.height; }
4923 #else
4924  if (m == PdmWidth)
4925  return data->crect.width();
4926  else
4927  return data->crect.height();
4928 #endif
4929  case PdmDepth:
4930  return 32;
4931  case PdmNumColors:
4932  return INT_MAX;
4933  case PdmDpiX:
4934  case PdmPhysicalDpiX: {
4935  Q_D(const QWidget);
4936  if (d->extra && d->extra->customDpiX)
4937  return d->extra->customDpiX;
4938  else if (d->parent)
4939  return static_cast<QWidget *>(d->parent)->metric(m);
4940  extern float qt_mac_defaultDpi_x(); //qpaintdevice_mac.cpp
4941  return int(qt_mac_defaultDpi_x()); }
4942  case PdmDpiY:
4943  case PdmPhysicalDpiY: {
4944  Q_D(const QWidget);
4945  if (d->extra && d->extra->customDpiY)
4946  return d->extra->customDpiY;
4947  else if (d->parent)
4948  return static_cast<QWidget *>(d->parent)->metric(m);
4949  extern float qt_mac_defaultDpi_y(); //qpaintdevice_mac.cpp
4950  return int(qt_mac_defaultDpi_y()); }
4951  default: //leave this so the compiler complains when new ones are added
4952  qWarning("QWidget::metric: Unhandled parameter %d", m);
4953  return QPaintDevice::metric(m);
4954  }
4955  return 0;
4956 }
double d
Definition: qnumeric_p.h:62
double qreal
Definition: qglobal.h:1193
int metric(PaintDeviceMetric) const
Internal implementation of the virtual QPaintDevice::metric() function.
QRect crect
Definition: qwidget.h:131
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
#define Q_D(Class)
Definition: qglobal.h:2482
float qt_mac_defaultDpi_y()
QWidgetData * data
Definition: qwidget.h:815
Q_CORE_EXPORT void qWarning(const char *,...)
QRect rect() const
friend OSViewRef qt_mac_nativeview_for(const QWidget *w)
Definition: qwidget_mac.mm:419
float qt_mac_defaultDpi_x()
virtual int metric(PaintDeviceMetric metric) const
#define INT_MAX
Q_DECL_CONSTEXPR int qRound(qreal d)
Definition: qglobal.h:1203

◆ minimumHeight()

int QWidget::minimumHeight ( ) const

◆ minimumSize()

QSize QWidget::minimumSize ( ) const

◆ minimumSizeHint()

virtual QSize QWidget::minimumSizeHint ( ) const
virtual

◆ minimumWidth()

int QWidget::minimumWidth ( ) const

◆ mouseDoubleClickEvent()

void QWidget::mouseDoubleClickEvent ( QMouseEvent event)
protectedvirtual

This event handler, for event event, can be reimplemented in a subclass to receive mouse double click events for the widget.

The default implementation generates a normal mouse press event.

Note
The widget will also receive mouse press and mouse release events in addition to the double click event. It is up to the developer to ensure that the application interprets these events correctly.
See also
mousePressEvent(), mouseReleaseEvent() mouseMoveEvent(), event(), QMouseEvent

Reimplemented in QCalendarView, QMdi::ControlLabel, QAbstractItemView, QTextEdit, QWorkspaceTitleBar, QGraphicsView, QPlainTextEdit, QLineEdit, QHeaderView, QTreeView, QSystemTrayIconSys, QMdiSubWindow, QAbstractScrollArea, and QColumnViewGrip.

Definition at line 9306 of file qwidget.cpp.

Referenced by event(), QMdiSubWindow::mouseDoubleClickEvent(), and setShown().

9307 {
9308  mousePressEvent(event); // try mouse press event
9309 }
virtual void mousePressEvent(QMouseEvent *)
This event handler, for event event, can be reimplemented in a subclass to receive mouse press events...
Definition: qwidget.cpp:9261

◆ mouseGrabber()

QWidget * QWidget::mouseGrabber ( )
static

◆ mouseMoveEvent()

void QWidget::mouseMoveEvent ( QMouseEvent event)
protectedvirtual

This event handler, for event event, can be reimplemented in a subclass to receive mouse move events for the widget.

If mouse tracking is switched off, mouse move events only occur if a mouse button is pressed while the mouse is being moved. 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. This is a feature of the underlying window system, not Qt.

If you want to show a tooltip immediately, while the mouse is moving (e.g., to get the mouse coordinates with QMouseEvent::pos() and show them as a tooltip), you must first enable mouse tracking as described above. Then, to ensure that the tooltip is updated immediately, you must call QToolTip::showText() instead of setToolTip() in your implementation of mouseMoveEvent().

See also
setMouseTracking(), mousePressEvent(), mouseReleaseEvent(), mouseDoubleClickEvent(), event(), QMouseEvent, {Scribble Example}

Reimplemented in QColorShowLabel, QCalendarView, QColorLuminancePicker, QColorPicker, QMdi::ControllerWidget, QColorWell, QAbstractItemView, QTextEdit, QWorkspaceTitleBar, QGraphicsView, QPlainTextEdit, QLineEdit, QHeaderView, QTreeView, QTabBar, QComboBoxPrivateScroller, QSplitterHandle, QMenu, QWhatsThat, QListView, QAbstractSpinBox, QTipLabel, QLabel, QAbstractButton, QMenuBar, QMdiSubWindow, QTextBrowser, QAbstractScrollArea, QSlider, QGroupBox, QMDIControl, QDial, QCheckBox, QColumnViewGrip, QScriptEditExtraArea, QScrollBar, QRadioButton, QSizeGrip, and QmlJSDebugger::ToolBarColorBox.

Definition at line 9239 of file qwidget.cpp.

Referenced by event(), QMdi::ControllerWidget::hasVisibleControls(), QSizeGrip::mouseMoveEvent(), QMdiSubWindow::mouseMoveEvent(), QColorWell::mouseMoveEvent(), QColorWell::QColorWell(), and setShown().

9240 {
9241  event->ignore();
9242 }

◆ mousePressEvent()

void QWidget::mousePressEvent ( QMouseEvent event)
protectedvirtual

This event handler, for event event, can be reimplemented in a subclass to receive mouse press events for the widget.

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.

The default implementation implements the closing of popup widgets when you click outside the window. For other widget types it does nothing.

See also
mouseReleaseEvent(), mouseDoubleClickEvent(), mouseMoveEvent(), event(), QMouseEvent, {Scribble Example}

Reimplemented in QColorShowLabel, QCalendarView, QColorLuminancePicker, QColorPicker, QMdiAreaTabBar, QMdi::ControllerWidget, QColorWell, QMdi::ControlLabel, QAbstractItemView, QTextEdit, QWorkspaceTitleBar, QGraphicsView, QComboBox, QComboBoxPrivateContainer, QPlainTextEdit, QLineEdit, QHeaderView, QTreeView, QTabBar, QDateTimeEdit, QSplitterHandle, QCalendarPopup, QSystemTrayIconSys, QMenu, QWhatsThat, QInputDialogDoubleSpinBox, QCalendarWidget, QWellArray, QAbstractSpinBox, QLabel, QAbstractButton, QMenuBar, QMdiSubWindow, QInputDialogSpinBox, QBalloonTip, QTextBrowser, QToolButton, QAbstractScrollArea, QSlider, QGroupBox, QMDIControl, QDial, QSplashScreen, QColumnViewGrip, QScriptEditExtraArea, QScrollBar, QSizeGrip, and QmlJSDebugger::ToolBarColorBox.

Definition at line 9261 of file qwidget.cpp.

Referenced by QComboBox::addItems(), event(), QCalendarWidget::isNavigationBarVisible(), mouseDoubleClickEvent(), QSizeGrip::mousePressEvent(), QMdiSubWindow::mousePressEvent(), QCalendarWidget::mousePressEvent(), QCalendarPopup::mousePressEvent(), QComboBox::mousePressEvent(), and setShown().

9262 {
9263  event->ignore();
9264  if ((windowType() == Qt::Popup)) {
9265  event->accept();
9266  QWidget* w;
9267  while ((w = QApplication::activePopupWidget()) && w != this){
9268  w->close();
9269  if (QApplication::activePopupWidget() == w) // widget does not want to disappear
9270  w->hide(); // hide at least
9271  }
9272  if (!rect().contains(event->pos())){
9273  close();
9274  }
9275  }
9276 }
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
const QPoint & pos() const
Returns the position of the mouse cursor, relative to the widget that received the event...
Definition: qevent.h:95
QRect rect() const
void hide()
Hides the widget.
Definition: qwidget.h:501
static QWidget * activePopupWidget()
Returns the active popup widget.
Qt::WindowType windowType() const
Returns the window type of this widget.
Definition: qwidget.h:937
bool close()
Closes this widget.
Definition: qwidget.cpp:8305

◆ mouseReleaseEvent()

void QWidget::mouseReleaseEvent ( QMouseEvent event)
protectedvirtual

◆ move() [1/2]

void QWidget::move ( int  x,
int  y 
)
inline

This corresponds to move(QPoint(x, y)).

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 1011 of file qwidget.h.

Referenced by QAxServerBase::ActiveXProc(), QWorkspace::addWindow(), QDialog::adjustPosition(), QWorkspace::arrangeIcons(), QBalloonTip::balloon(), QX11Data::dndEnable(), do_size_hints(), QStatusBar::event(), QAlphaWidget::eventFilter(), findRealWindow(), QWorkspacePrivate::insertIcon(), QComboBox::keyPressEvent(), QTabBarPrivate::layoutTab(), QWidgetResizeHandler::mouseMoveEvent(), QToolBarPrivate::mouseMoveEvent(), QWorkspaceTitleBar::mouseMoveEvent(), QRubberBand::move(), QTipLabel::placeTip(), QDateTimeEditPrivate::positionCalendarPopup(), qt_x11_recreateWidget(), QtWndProc(), qWinProcessConfigRequests(), QWorkspaceChild::QWorkspaceChild(), QApplication::qwsProcessEvent(), QWorkspaceChild::resizeEvent(), QExpandingLineEdit::resizeToContents(), restoreGeometry(), QDockAreaLayoutInfo::restoreState(), QAlphaWidget::run(), QRollEffect::run(), QWhatsThisPrivate::say(), QRollEffect::scroll(), QDockWidget::setFloating(), QSplashScreen::setPixmap(), QMdiSubWindowPrivate::setSizeGrip(), setWindowFlags(), QScrollAreaPrivate::updateWidgetPosition(), and QWorkspacePrivate::updateWorkspace().

1012 { move(QPoint(ax, ay)); }
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
void move(int x, int y)
This corresponds to move(QPoint(x, y)).
Definition: qwidget.h:1011

◆ move() [2/2]

void QWidget::move ( const QPoint p)

Definition at line 7174 of file qwidget.cpp.

7175 {
7176  Q_D(QWidget);
7178  if (isWindow())
7179  d->topData()->posFromMove = true;
7181  d->setGeometry_sys(p.x() + geometry().x() - QWidget::x(),
7182  p.y() + geometry().y() - QWidget::y(),
7183  width(), height(), true);
7184  d->setDirtyOpaqueRegion();
7185  } else {
7186  data->crect.moveTopLeft(p); // no frame yet
7188  }
7189 }
double d
Definition: qnumeric_p.h:62
int y() const
QRect crect
Definition: qwidget.h:131
bool isWindow() const
Returns true if the widget is an independent window, otherwise returns false.
Definition: qwidget.h:945
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_D(Class)
Definition: qglobal.h:2482
int height() const
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
int width() const
QWidgetData * data
Definition: qwidget.h:815
void moveTopLeft(const QPoint &p)
Moves the rectangle, leaving the top-left corner at the given position.
Definition: qrect.h:368
int x() const
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252
int y() const
Returns the y coordinate of this point.
Definition: qpoint.h:131
void setAttribute(Qt::WidgetAttribute, bool on=true)
Sets the attribute attribute on this widget if on is true; otherwise clears the attribute.
Definition: qwidget.cpp:11087
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128
const QRect & geometry() const

◆ moveEvent()

void QWidget::moveEvent ( QMoveEvent event)
protectedvirtual

This event handler can be reimplemented in a subclass to receive widget move events which are passed in the event parameter.

When the widget receives this event, it is already at the new position.

The old position is accessible through QMoveEvent::oldPos().

See also
resizeEvent(), event(), move(), QMoveEvent

Reimplemented in QWorkspaceChild, QMdiSubWindow, QRubberBand, QSizeGrip, and QWSEmbedWidget.

Definition at line 9566 of file qwidget.cpp.

Referenced by event(), QMdiSubWindow::moveEvent(), QRubberBand::resize(), and setShown().

9567 {
9568 }

◆ nativeParentWidget()

QWidget * QWidget::nativeParentWidget ( ) const

Returns the native parent for this widget, i.

Since
4.4

e. the next ancestor widget that has a system identifier, or 0 if it does not have any native parent.

See also
effectiveWinId()

Definition at line 4514 of file qwidget.cpp.

Referenced by QX11PaintEngine::begin(), QPainter::begin(), QWindowsVistaStyle::drawComplexControl(), effectiveWinId(), flipPoint(), ShivaVGWindowSurface::flush(), QVGWindowSurface::flush(), QGLWindowSurface::flush(), QWidgetPrivate::hide_sys(), QWidgetPrivate::isBackgroundInherited(), QWidgetBackingStore::markDirtyOnScreen(), QBBNativeInterface::nativeResourceForWidget(), q_createNativeChildrenAndSetParent(), qt_grab_cursor(), qt_mac_update_widget_position(), qt_mac_updateParentUnderAlienWidget(), qt_x11_enforce_cursor(), QWidgetPrivate::scroll_sys(), QWidgetPrivate::show_sys(), QWidgetBackingStore::showYellowThing(), QXIMInputContext::update(), updateRedirectedToGraphicsProxyWidget(), and QApplication::x11ProcessEvent().

4515 {
4517  while (parent && !parent->internalWinId())
4518  parent = parent->parentWidget();
4519  return parent;
4520 }
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
QObject * parent() const
Returns a pointer to the parent object.
Definition: qobject.h:273
WId internalWinId() const
Returns the window system identifier of the widget, or 0 if the widget is not created yet...
Definition: qwidget.h:244

◆ nextInFocusChain()

QWidget * QWidget::nextInFocusChain ( ) const

Returns the next widget in this widget's focus chain.

See also
previousInFocusChain()

Definition at line 6873 of file qwidget.cpp.

Referenced by QGroupBoxPrivate::_q_fixFocus(), QAxServerBase::ActiveXProc(), QX11EmbedWidgetPrivate::getFocusWidget(), iWantTheFocus(), QtWndProc(), QMdiSubWindowPrivate::setFocusWidget(), QDialog::setVisible(), and QAxServerBase::TranslateAcceleratorW().

6874 {
6875  return const_cast<QWidget *>(d_func()->focus_next);
6876 }
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150

◆ normalGeometry()

QRect QWidget::normalGeometry ( ) const

Referenced by saveGeometry(), and setDisabled().

◆ overrideWindowFlags()

void QWidget::overrideWindowFlags ( Qt::WindowFlags  flags)

Sets the window flags for the widget to flags, without telling the window system.

Warning
Do not call this function unless you really know what you're doing.
See also
setWindowFlags()

Definition at line 10434 of file qwidget.cpp.

10435 {
10436  data->window_flags = flags;
10437 }
Qt::WindowFlags window_flags
Definition: qwidget.h:119
QWidgetData * data
Definition: qwidget.h:815

◆ overrideWindowState()

void QWidget::overrideWindowState ( Qt::WindowStates  newstate)
Warning
This function is not part of the public interface.

The function sets the window state on child widgets similar to setWindowState(). The difference is that the window state changed event has the isOverride() flag set. It exists mainly to keep Q3Workspace working.

Definition at line 3098 of file qwidget.cpp.

Referenced by QWorkspaceChild::adjustToFullscreen(), QMdiSubWindowPrivate::ensureWindowState(), QWorkspaceChild::eventFilter(), QWorkspacePrivate::maximizeWindow(), QWorkspacePrivate::minimizeWindow(), QWorkspacePrivate::normalizeWindow(), QWorkspaceChild::resizeEvent(), QMdiSubWindowPrivate::setActive(), and QWorkspaceChild::showShaded().

3099 {
3100  QWindowStateChangeEvent e(Qt::WindowStates(data->window_state), true);
3101  data->window_state = newstate;
3102  QApplication::sendEvent(this, &e);
3103 }
uint window_state
Definition: qwidget.h:120
QWidgetData * data
Definition: qwidget.h:815
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
The QWindowStateChangeEvent class provides the window state before a window state change...
Definition: qevent.h:705

◆ paintEngine()

QPaintEngine * QWidget::paintEngine ( ) const
virtual

Returns the widget's paint engine.

Note that this function should not be called explicitly by the user, since it's meant for reimplementation purposes only. The function is called by Qt internally, and the default implementation may not always return a valid pointer.

Implements QPaintDevice.

Reimplemented in QGLWidget.

Definition at line 5188 of file qwidget_mac.mm.

Referenced by QWidgetPrivate::drawWidget(), effectiveState(), make_widget_eventUPP(), setAttribute(), QWidgetPrivate::setWindowRole(), and QWidgetBackingStore::showYellowThing().

5189 {
5190  QPaintEngine *&pe = engineHandler()->engine;
5191  if (!pe)
5192  pe = new QCoreGraphicsPaintEngine();
5193  if (pe->isActive()) {
5194  QPaintEngine *engine = new QCoreGraphicsPaintEngine();
5195  engine->setAutoDestruct(true);
5196  return engine;
5197  }
5198  return pe;
5199 }
void setAutoDestruct(bool autoDestr)
Definition: qpaintengine.h:249
bool isActive() const
Returns true if the paint engine is actively drawing; otherwise returns false.
Definition: qpaintengine.h:154
The QPaintEngine class provides an abstract definition of how QPainter draws to a given device on a g...
Definition: qpaintengine.h:90

◆ paintEvent()

void QWidget::paintEvent ( QPaintEvent event)
protectedvirtual

This event handler can be reimplemented in a subclass to receive paint events passed in event.

A paint event is a request to repaint all or part of a widget. It can happen for one of the following reasons:

  • repaint() or update() was invoked,
  • the widget was obscured and has now been uncovered, or
  • many other reasons.

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 QTableView 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::united()). The repaint() function does not permit this optimization, so we suggest using update() whenever possible.

When the paint event occurs, the update region has normally been erased, so you are painting on the widget's background.

The background can be set using setBackgroundRole() and setPalette().

Since Qt 4.0, QWidget automatically double-buffers its painting, so there is no need to write double-buffering code in paintEvent() to avoid flicker.

Note for the X11 platform: It is possible to toggle global double buffering by calling qt_x11_set_global_double_buffer(). For example,

Note
Generally, you should refrain from calling update() or repaint() inside a paintEvent(). For example, calling update() or repaint() on children inside a paintevent() results in undefined behavior; the child may or may not get a paint event.
Warning
If you are using a custom paint engine without Qt's backingstore, Qt::WA_PaintOnScreen must be set. Otherwise, QWidget::paintEngine() will never be called; the backingstore will be used instead.
See also
event(), repaint(), update(), QPainter, QPixmap, QPaintEvent, {Analog Clock Example}

Reimplemented in QPrevNextCalButton, QCalToolButton, QColorShowLabel, QWorkspaceChild, QColorLuminancePicker, QColorPicker, QTableCornerButton, QGLWidget, QMdi::ControllerWidget, QWizardAntiFlickerWidget, QMdi::ControlLabel, QFileDialogComboBox, QRollEffect, QShapedPixmapWidget, QTextEdit, QWizardHeader, QWorkspaceTitleBar, QGraphicsView, CloseButton, QComboBox, QPlainTextEdit, QLineEdit, QHeaderView, QDateTimeEdit, QTabBar, QWizard, QComboBoxPrivateScroller, QTreeView, QMenu, QSplitterHandle, QListView, QWhatsThat, QTabWidget, QPagePreview, QSystemTrayIconSys, QWellArray, QMdiArea, QAbstractSpinBox, QTableView, QToolBar, QTipLabel, QLabel, QMenuBar, QAxHostWidget, QAbstractButton, QFrame, QMdiSubWindow, QDockWidgetTitleButton, QDockWidget, QLCDNumber, QTextBrowser, QProgressBar, QX11EmbedContainer, QToolButton, QBalloonTip, QShapedPixmapWidget, QWorkspace, QDeclarativeView, QAbstractScrollArea, QComboBoxListView, QSlider, QPushButton, QStatusBar, QGroupBox, QScriptEdit, QMenuBarExtension, QMDIControl, QDial, QCheckBox, QRubberBand, QToolBoxButton, QVistaBackButton, QColumnViewGrip, QToolBarSeparator, QCommandLinkButton, QAlphaWidget, QSvgWidget, QScrollBar, QScriptEditExtraArea, QFocusFrame, QRadioButton, QToolBarExtension, and QSizeGrip.

Definition at line 9548 of file qwidget.cpp.

Referenced by QComboBox::addItems(), event(), QToolBar::isAreaAllowed(), QDockWidget::isAreaAllowed(), QMdiSubWindow::paintEvent(), QRubberBand::resize(), setShown(), and QProgressBar::textDirection().

9549 {
9550 }

◆ palette()

const QPalette& QWidget::palette ( ) const

◆ paletteChange()

void QWidget::paletteChange ( const QPalette )
protectedvirtual
Warning
This function is not part of the public interface.

Definition at line 12002 of file qwidget.cpp.

12002 { } // compat

◆ parentWidget()

QWidget * QWidget::parentWidget ( ) const
inline

Returns the parent of this widget, or 0 if it does not have any parent widget.

Use the no-argument overload instead.

Definition at line 1035 of file qwidget.h.

Referenced by QMenuPrivate::_q_actionTriggered(), QAccessibleAbstractScrollArea::accessibleChildren(), QWorkspaceChild::activate(), activateWindow(), QDialogButtonBoxPrivate::addButton(), QLayout::addChildWidget(), QSystemTrayIconSys::addToTray(), QWorkspaceChild::adjustToFullscreen(), QToolBar::allowedAreas(), QMainWindowLayout::animationFinished(), QFormLayoutPrivate::arrangeWidgets(), QWidgetPrivate::assignedInputContext(), axc_FilterProc(), backgroundRole(), buddyString(), bypassGraphicsProxyWidget(), QDockWidget::changeEvent(), QToolButton::changeEvent(), QMenuBar::changeEvent(), QWorkspaceChild::changeEvent(), QWorkspaceChild::childEvent(), clearFocus(), QWidgetPrivate::clipRect(), QWidgetPrivate::clipRegion(), QWidgetPrivate::clipToEffectiveMask(), QWidgetPrivate::close_helper(), QMdiSubWindow::closeEvent(), containerWidget(), QDialog::contextMenuEvent(), QMainWindow::contextMenuEvent(), QMdi::ControllerWidget::ControllerWidget(), QShortcutMap::correctWidgetContext(), AccessibleFactory::create(), create(), QWidgetPrivate::create_sys(), QAxWidget::createHostWindow(), QFileDialogPrivate::createNavServicesDialog(), QMainWindow::createPopupMenu(), QGraphicsProxyWidget::createProxyForChildWidget(), QEgl::createSurface(), QWidgetPrivate::createWinId(), QPushButtonPrivate::dialogParent(), QApplicationPrivate::dispatchEnterLeave(), QGridLayoutPrivate::distribute(), do_size_hints(), QLayoutPrivate::doResize(), QColorWell::dragLeaveEvent(), QGraphicsProxyWidget::dragMoveEvent(), QOleDropTarget::DragOver(), QWindowsCEStyle::drawComplexControl(), QWindowsMobileStyle::drawComplexControl(), QMacStyle::drawComplexControl(), QCommonStyle::drawControl(), QPlastiqueStyle::drawControl(), QCleanlooksStyle::drawControl(), QWindowsStyle::drawControl(), QGtkStyle::drawControl(), QMacStyle::drawControl(), QGraphicsScene::drawItems(), QWindowsCEStyle::drawPrimitive(), QCommonStyle::drawPrimitive(), QWindowsVistaStyle::drawPrimitive(), QWindowsMobileStyle::drawPrimitive(), QPlastiqueStyle::drawPrimitive(), QWindowsXPStyle::drawPrimitive(), QWindowsStyle::drawPrimitive(), QMacStyle::drawPrimitive(), QStyleSheetStyle::drawPrimitive(), QWidgetEffectSourcePrivate::effectBoundingRectChanged(), QBoxLayoutPrivate::effectiveMargins(), effectiveState(), QWorkspaceTitleBar::enterEvent(), QGraphicsProxyWidget::event(), QDialog::event(), QDockWidget::event(), QMacStyle::event(), QMenuBar::event(), QToolBar::event(), QDialogButtonBox::event(), QApplication::event(), QStyledItemDelegate::eventFilter(), QItemDelegate::eventFilter(), QMdiSubWindow::eventFilter(), QWorkspaceChild::eventFilter(), QToolBarLayout::expandedSize(), QGestureManager::filterEvent(), findMenubarForWindow(), findParentforPopup(), focusNextPrevChild(), QLineEdit::focusOutEvent(), QWidgetPrivate::frameStrut(), QGraphicsItemPrivate::genericMapFromScene(), QGestureManager::getGestureTargets(), QLayoutPrivate::getMargin(), getNetWmState(), QMainWindowLayout::getSeparatorWidget(), QFormLayoutPrivate::getStyle(), QMainWindowLayout::getTabBar(), QApplicationPrivate::giveFocusAccordingToFocusPolicy(), QApplicationPrivate::globalEventProcessor(), handle_xdnd_position(), QMenuBarPrivate::handleReparent(), QWidgetPrivate::hide_helper(), QWidgetPrivate::hide_sys(), QWorkspaceChild::iconWidget(), QAccessibleComboBox::indexOfChild(), QWidgetPrivate::inheritStyle(), QToolBarPrivate::init(), QGLWidgetPrivate::init(), QWidgetPrivate::init(), QTabBarPrivate::initStyleBaseOption(), QToolBoxButton::initStyleOption(), QToolButton::initStyleOption(), QToolBar::initStyleOption(), QWorkspacePrivate::insertIcon(), QSplitterPrivate::insertWidget_helper(), QWorkspaceChild::internalRaise(), QWidgetPrivate::invalidateGraphicsEffectsRecursively(), QWidgetPrivate::isAboutToShow(), isAncestorOf(), QWidgetPrivate::isBackgroundInherited(), QApplicationPrivate::isBlockedByModal(), isChildOf(), isChildOfQMdiSubWindow(), isEnabledTo(), QWindowsXPStylePrivate::isItemViewDelegateLineEdit(), QWidgetPrivate::isOverlapped(), isServerProcess(), isTreeView(), isVisibleTo(), QGraphicsScenePrivate::itemsAtPosition(), QMdiSubWindow::keyPressEvent(), QAbstractButton::keyPressEvent(), lower(), make_widget_eventUPP(), make_win_eventUPP(), mapFrom(), mapTo(), QGestureEvent::mapToGraphicsScene(), QWorkspacePrivate::maximizeWindow(), QMdiSubWindow::mdiArea(), mdiAreaNavigate(), mdiAreaParent(), QToolBoxButton::minimumSizeHint(), QMenuBar::minimumSizeHint(), QColumnViewGrip::mouseDoubleClickEvent(), QWidgetResizeHandler::mouseMoveEvent(), QSplitterHandle::mouseMoveEvent(), QWorkspaceTitleBar::mouseMoveEvent(), QGraphicsItem::mouseMoveEvent(), QSizeGrip::mousePressEvent(), QCalendarPopup::mousePressEvent(), QSplitterHandle::mouseReleaseEvent(), QToolBarLayout::movable(), QWorkspaceChild::moveEvent(), QColumnViewGrip::moveGrip(), QWidgetPrivate::moveRect(), nativeParentWidget(), QBBNativeInterface::nativeResourceForWidget(), QWidgetPrivate::naturalWidgetFont(), QWidgetPrivate::naturalWidgetPalette(), QAccessibleWidget::navigate(), QAccessibleMenu::navigate(), QAccessibleAbstractScrollArea::navigate(), QAccessibleMdiSubWindow::navigate(), QAccessibleComboBox::navigate(), QWidgetPrivate::nearestGraphicsProxyWidget(), QWorkspacePrivate::normalizeWindow(), QApplication::notify(), QDialog::open(), QPrintDialogPrivate::openWindowsPrintDialogModally(), QToolBarSeparator::paintEvent(), QToolBoxButton::paintEvent(), QSplitterHandle::paintEvent(), QGLOverlayWidget::paintGL(), parentWidget(), QWindowsMobileStyle::pixelMetric(), QMacStyle::pixelMetric(), QStyleSheetStyle::pixelMetric(), QMainWindowLayout::plug(), QWindowsXPStyle::polish(), previousInFocusChain(), q_createNativeChildrenAndSetParent(), QBBWindow::QBBWindow(), QMenuBarExtension::QMenuBarExtension(), qstring_to_xtp(), qt_aqua_get_known_size(), qt_check_if_internal_widget(), qt_event_request_showsheet(), qt_grab_cursor(), qt_mac_can_clickThrough(), qt_mac_get_widget_rgn(), qt_mac_is_ancestor(), qt_mac_is_macdrawer(), qt_mac_is_macsheet(), qt_mac_is_metal(), qt_mac_mouse_inside_answer_rect(), qt_mac_nativeMapFromParent(), qt_mac_posInWindow(), qt_mac_post_retranslateAppMenu(), qt_mac_should_disable_menu(), qt_mac_unregister_widget(), qt_mac_update_widget_position(), qt_mac_updateCursorWithWidgetUnderMouse(), qt_nograb(), qt_sizegrip_topLevelWidget(), qt_try_modal(), qt_x11_enforce_cursor(), qt_x11_recreateWidget(), QToolBarLayout::QToolBarLayout(), QTornOffMenu::QTornOffMenu(), QtWndProc(), QApplication::qwsProcessEvent(), QXcbWindow::QXcbWindow(), raise(), QWidgetPrivate::raise_sys(), QLayoutPrivate::reparentChildWidgets(), QProgressDialog::reset(), QWorkspaceChild::resizeEvent(), QExpandingLineEdit::resizeToContents(), QMdiAreaPrivate::resizeToMinimumTileSize(), QGraphicsWidgetPrivate::resolveLayoutDirection(), QApplicationPrivate::sendSyntheticEnterLeave(), QGraphicsProxyWidgetPrivate::sendWidgetKeyEvent(), setAttribute(), QProgressDialog::setCancelButton(), QAbstractScrollArea::setCornerWidget(), QTabWidget::setCornerWidget(), QWidgetPrivate::setDirtyOpaqueRegion(), QToolBarLayout::setExpanded(), QDialog::setExtension(), setFocus(), QToolBarLayout::setGeometry(), QMainWindowLayout::setGeometry(), QWidgetPrivate::setGeometry_sys(), QToolBar::setIconSize(), QProgressDialog::setLabel(), setMask(), QMdiSubWindowPrivate::setMaximizeMode(), QWidgetPrivate::setModal_sys(), QMenuBar::setNativeMenuBar(), setParent(), QWidgetPrivate::setParent_sys(), QDeclarativeView::setRootObject(), QWellArray::setSelected(), QTabWidget::setTabBar(), QBoxLayoutPrivate::setupGeom(), QGridLayoutPrivate::setupSpacings(), QFormLayoutPrivate::setupVerticalLayoutData(), QDialog::setVisible(), QPageSetupDialog::setVisible(), QColorDialog::setVisible(), QPrintDialog::setVisible(), QXlibWindow::setVisible(), setVisible(), QFocusFrame::setWidget(), QScrollArea::setWidget(), QGraphicsProxyWidgetPrivate::setWidget_helper(), setWindowFlags(), QMessageBox::setWindowModality(), setWindowTitle(), QWidgetPrivate::show_sys(), QFontDialogPrivate::showCocoaFontPanel(), QDialog::showEvent(), QWorkspacePrivate::showMaximizeControls(), QWorkspaceChild::showShaded(), QWorkspacePrivate::showWindow(), QCleanlooksStyle::sizeFromContents(), QMacStyle::sizeFromContents(), QGtkStyle::sizeFromContents(), QStyleSheetStyle::sizeFromContents(), QPushButton::sizeHint(), QToolBarSeparator::sizeHint(), QToolBoxButton::sizeHint(), QMenuBarExtension::sizeHint(), QMdiArea::sizeHint(), QMenuBar::sizeHint(), QSplitterHandle::sizeHint(), QSoftKeyManager::softkeySource(), stackUnder(), QWidgetPrivate::stackUnder_sys(), QAccessibleMdiSubWindow::state(), QMacStyle::styleHint(), QMacStyle::subControlRect(), QMacStyle::subElementRect(), QStyleSheetStyle::subElementRect(), QWidgetPrivate::subtractOpaqueSiblings(), testAttribute(), toolbarInUnifiedToolBar(), QETWidget::translateMouseEvent(), unsetLayoutDirection(), unstylable(), QAccessible::updateAccessibility(), QWidgetPrivate::updateGeometry_helper(), QMenuPrivate::updateLayoutDirection(), QWorkspaceChild::updateMask(), QGraphicsProxyWidgetPrivate::updateProxyGeometryFromWidget(), updateRedirectedToGraphicsProxyWidget(), QFocusFramePrivate::updateSize(), QMdi::ControlLabel::updateWindowIcon(), QHeaderView::viewportEvent(), QWizardHeader::vistaDisabled(), waitForPopup(), QLayout::widgetEvent(), QMacStyle::widgetSizePolicy(), window(), windowSurface(), QApplication::winFocus(), QApplication::x11ClientMessage(), QToolBar::~QToolBar(), and QWorkspaceChild::~QWorkspaceChild().

1036 { return static_cast<QWidget *>(QObject::parent()); }
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
QObject * parent() const
Returns a pointer to the parent object.
Definition: qobject.h:273

◆ pos()

QPoint QWidget::pos ( ) const

Referenced by QMainWindowPrivate::adjustCursor(), QSplitterPrivate::adjustPos(), QDialog::adjustPosition(), axc_FilterProc(), QTreeViewPrivate::calcLogicalIndices(), QGraphicsView::centerOn(), QAbstractSpinBox::contextMenuEvent(), QDateTimeEdit::dateTimeFromText(), QAbstractItemView::doAutoScroll(), QSplitterPrivate::doResize(), QLCDNumberPrivate::drawSegment(), QLCDNumberPrivate::drawString(), QScriptDebuggerCodeView::event(), QGroupBox::event(), QStatusBar::event(), QDockWidget::event(), QToolBar::event(), QTabBar::event(), QMainWindow::event(), event(), QTipLabel::eventFilter(), QCalendarWidget::eventFilter(), QMenu::exec(), fixToolBarOrientation(), QCalendarView::handleMouseEvent(), QAccessibleDisplay::imagePosition(), QToolButton::initStyleOption(), insertAction(), QMenu::internalDelayedPopup(), QMdiSubWindow::keyPressEvent(), QDateTimeEdit::keyPressEvent(), QVistaHelper::leftMargin(), mapTo(), QHeaderView::mouseDoubleClickEvent(), QMenuPrivate::mouseEventTaken(), QTipLabel::mouseMoveEvent(), QSplitterHandle::mouseMoveEvent(), QComboBoxPrivateScroller::mouseMoveEvent(), QHeaderView::mouseMoveEvent(), QPlainTextEdit::mouseMoveEvent(), QTextEdit::mouseMoveEvent(), QWellArray::mousePressEvent(), QHeaderView::mousePressEvent(), QAbstractItemView::mousePressEvent(), QSplitterHandle::mouseReleaseEvent(), QHeaderView::mouseReleaseEvent(), QAbstractItemView::mouseReleaseEvent(), QSplitter::moveSplitter(), QSplitterHandle::moveSplitter(), parseGeometry(), QTipLabel::placeTip(), QMenu::popup(), QMenuBarPrivate::popupAction(), QtWndProc(), QApplication::qwsProcessEvent(), QTreeViewPrivate::renderTreeToPixmapForAnimation(), QHeaderView::resizeSection(), QExpandingLineEdit::resizeToContents(), QHeaderViewPrivate::sectionHandleAt(), QLineEdit::selectionStart(), QMainWindowLayout::separatorMove(), setDisabled(), QComboBox::setModel(), QTabWidget::setTabPosition(), setWindowFlags(), QToolTip::showText(), QMainWindowLayout::startSeparatorMove(), QWorkspace::tile(), QTreeView::timerEvent(), QPlainTextEdit::timerEvent(), QTextEdit::timerEvent(), QETWidget::translateMouseEvent(), QMenuBarPrivate::updateGeometries(), QTabWidgetPrivate::updateTabBarPosition(), QSpinBox::valueFromText(), QDoubleSpinBox::valueFromText(), QAbstractItemView::viewportEvent(), and QComboBoxPrivate::~QComboBoxPrivate().

◆ previousInFocusChain()

QWidget * QWidget::previousInFocusChain ( ) const

The previousInFocusChain function returns the previous widget in this widget's focus chain.

See also
nextInFocusChain()
Since
4.6

Definition at line 6889 of file qwidget.cpp.

6890 {
6891  return const_cast<QWidget *>(d_func()->focus_prev);
6892 }
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150

◆ qwsEvent()

bool QWidget::qwsEvent ( QWSEvent event)
protectedvirtual

This special event handler can be reimplemented in a subclass to receive native Qt for Embedded Linux events which are passed in the event parameter.

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

Definition at line 9993 of file qwidget.cpp.

Referenced by QApplication::qwsProcessEvent(), and setShown().

9994 {
9995  return false;
9996 }

◆ raise

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.

Note
When using activateWindow(), you can call this function to ensure that the window is stacked on top.
See also
lower(), stackUnder()

Definition at line 11901 of file qwidget.cpp.

Referenced by QCalendarWidgetPrivate::_q_yearClicked(), QMessageBox::about(), QMessageBox::aboutQt(), QAxServerBase::ActiveXProc(), QWidgetPrivate::createWinId(), effectiveState(), QApplicationPrivate::globalEventProcessor(), QMdiAreaPrivate::internalRaise(), QWorkspaceChild::internalRaise(), qt_try_modal(), QApplication::qwsProcessEvent(), QStackedLayout::setCurrentIndex(), QToolBarLayout::setExpanded(), QMdiSubWindowPrivate::setSizeGrip(), QComboBox::showPopup(), QMdiAreaPrivate::showRubberBandFor(), QDockAreaLayoutInfo::updateSeparatorWidgets(), QDockAreaLayout::updateSeparatorWidgets(), and QApplication::x11ClientMessage().

11902 {
11903  Q_D(QWidget);
11904  if (!isWindow()) {
11905  QWidget *p = parentWidget();
11906  const int parentChildCount = p->d_func()->children.size();
11907  if (parentChildCount < 2)
11908  return;
11909  const int from = p->d_func()->children.indexOf(this);
11910  Q_ASSERT(from >= 0);
11911  // Do nothing if the widget is already in correct stacking order _and_ created.
11912  if (from != parentChildCount -1)
11913  p->d_func()->children.move(from, parentChildCount - 1);
11915  create();
11916  else if (from == parentChildCount - 1)
11917  return;
11918 
11919  QRegion region(rect());
11920  d->subtractOpaqueSiblings(region);
11921  d->invalidateBuffer(region);
11922  }
11924  d->raise_sys();
11925 
11927  QApplication::sendEvent(this, &e);
11928 }
double d
Definition: qnumeric_p.h:62
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
bool isWindow() const
Returns true if the widget is an independent window, otherwise returns false.
Definition: qwidget.h:945
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define Q_D(Class)
Definition: qglobal.h:2482
void move(int from, int to)
Moves the item at index position from to index position to.
Definition: qlist.h:628
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
void create(WId=0, bool initializeWindow=true, bool destroyOldWindow=true)
Creates a new widget window if window is 0, otherwise sets the widget&#39;s window to window...
Definition: qwidget.cpp:1454
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
QRect rect() const
int indexOf(const T &t, int from=0) const
Returns the index position of the first occurrence of value in the list, searching forward from index...
Definition: qlist.h:847
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
const QObjectList & children() const
Returns a list of child objects.
Definition: qobject.h:197
The QEvent class is the base class of all event classes.
Definition: qcoreevent.h:56

◆ rect()

QRect QWidget::rect ( ) const
inline

Referenced by QMenuPrivate::actionAt(), QLineEditPrivate::adjustedControlRect(), QPushButtonPrivate::adjustedMenuPosition(), QDialog::adjustPosition(), QWorkspaceChild::adjustToFullscreen(), QDesktopWidget::availableGeometry(), QTreeViewPrivate::beginAnimatedOperation(), QMenuBarPrivate::calcActionRects(), QDialog::contextMenuEvent(), QAbstractItemViewPrivate::draggablePaintPairs(), QListViewPrivate::draggablePaintPairs(), QAbstractItemView::dragMoveEvent(), QGroupBox::event(), QTipLabel::eventFilter(), QComboBoxPrivateContainer::eventFilter(), QScriptEdit::extraAreaPaintEvent(), QAbstractItemViewPrivate::fetchMore(), fillRegion(), QSystemTrayIconSys::findIconGeometry(), QAxClientSite::GetIDsOfNames(), QMenuBar::heightForWidth(), QAbstractButton::hitButton(), QAbstractItemView::horizontalScrollbarValueChanged(), QListViewPrivate::horizontalScrollToValue(), QListView::indexAt(), QDesktopWidgetPrivate::init(), QMenuBar::initStyleOption(), QMenu::initStyleOption(), QGraphicsView::invalidateScene(), QWidgetPrivate::isOverlapped(), QTreeViewPrivate::itemDecorationRect(), QAbstractItemView::keyPressEvent(), QMenuBar::minimumSizeHint(), QAbstractSpinBox::minimumSizeHint(), QScrollBar::mouseMoveEvent(), QCheckBox::mouseMoveEvent(), QTipLabel::mouseMoveEvent(), QListView::mouseMoveEvent(), QMenu::mouseMoveEvent(), QComboBoxPrivateScroller::mouseMoveEvent(), QWorkspaceTitleBar::mouseMoveEvent(), QWhatsThat::mousePressEvent(), QMenu::mousePressEvent(), QCalendarPopup::mousePressEvent(), QWorkspaceTitleBar::mousePressEvent(), QAbstractItemView::mousePressEvent(), mousePressEvent(), QmlJSDebugger::ZoomTool::mouseReleaseEvent(), QWhatsThat::mouseReleaseEvent(), QLineEdit::mouseReleaseEvent(), QPlainTextEdit::mouseReleaseEvent(), QWorkspaceTitleBar::mouseReleaseEvent(), QTextEdit::mouseReleaseEvent(), QListView::moveCursor(), QAbstractButtonPrivate::moveFocus(), QComboBoxDelegate::paint(), QCalendarDelegate::paint(), QWellArray::paintCell(), QCalendarDelegate::paintCell(), QFocusFrame::paintEvent(), QVistaBackButton::paintEvent(), QBalloonTip::paintEvent(), QMdiSubWindow::paintEvent(), QMenuBar::paintEvent(), QWellArray::paintEvent(), QSystemTrayIconSys::paintEvent(), QWhatsThat::paintEvent(), QMenu::paintEvent(), QComboBoxPrivateScroller::paintEvent(), QTabBar::paintEvent(), QLineEdit::paintEvent(), QGraphicsView::paintEvent(), QWorkspaceChild::paintEvent(), QGLOverlayWidget::paintGL(), QHeaderView::paintSection(), QToolButtonPrivate::popupTimerDone(), QAbstractItemViewPrivate::position(), QTreeViewPrivate::prepareAnimatedOperation(), QCalendarDelegate::QCalendarDelegate(), QApplication::qwsProcessEvent(), raise(), QAccessibleMenuItem::rect(), QAccessibleItemView::rect(), QAccessibleDial::rect(), QAccessibleComboBox::rect(), QAccessibleDockWidget::rect(), QWidgetPrivate::render_helper(), repaint(), QWSEmbedWidget::resizeEvent(), QDeclarativeView::resizeEvent(), QDialog::resizeEvent(), QAxHostWidget::resizeObject(), QmlJSDebugger::ZoomTool::scaleView(), QDesktopWidget::screenGeometry(), scroll(), QListView::scrollTo(), QTreeView::scrollTo(), QmlJSDebugger::SubcomponentMaskLayerItem::setCurrentItem(), QMenuPrivate::setFirstActionActive(), QFrame::setFrameRect(), setGeometry(), setGraphicsEffect(), setMask(), QGraphicsView::setSceneRect(), QDialog::setSizeGripEnabled(), QTipLabel::setTipRect(), QHeaderViewPrivate::setupSectionIndicator(), QWSEmbedWidget::showEvent(), QMenuBar::sizeHint(), QAbstractSpinBox::sizeHint(), QMenu::sizeHint(), QDateTimeEdit::sizeHint(), QAbstractItemView::startDrag(), QAccessibleTable2Cell::state(), QTabBar::tabRect(), QTableView::timerEvent(), QTreeView::timerEvent(), QTipLabel::tipChanged(), QVistaHelper::topPadding(), QAbstractItemView::update(), update(), QMenuPrivate::updateActionRects(), QScriptEdit::updateExtraArea(), QMenuBarPrivate::updateGeometries(), QWorkspaceChild::updateMask(), QGraphicsView::updateScene(), QGraphicsView::updateSceneRect(), QAbstractItemView::verticalScrollbarValueChanged(), QListViewPrivate::verticalScrollToValue(), QTreeView::viewportEvent(), QColumnView::visualRect(), QListView::visualRegionForSelection(), QMenu::wheelEvent(), and QApplication::x11ProcessEvent().

◆ releaseDC()

void QWidget::releaseDC ( HDC  hdc) const
virtual

Releases the HDC hdc acquired by a previous call to getDC().

Warning
Using this function is not portable.

Reimplemented from QPaintDevice.

Definition at line 11862 of file qwidget.cpp.

Referenced by QRasterWindowSurface::flush(), and showYellowThing_win().

11863 {
11864  Q_D(const QWidget);
11865  // If its the widgets own dc, it will be released elsewhere. If
11866  // its a different HDC we release it and issue a warning if it
11867  // fails.
11868  if (hdc != d->hd && !ReleaseDC(winId(), hdc))
11869  qErrnoWarning("QWidget::releaseDC(): failed to release HDC");
11870 }
double d
Definition: qnumeric_p.h:62
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_D(Class)
Definition: qglobal.h:2482
WId winId() const
Returns the window system identifier of the widget.
Definition: qwidget.cpp:2557
void qErrnoWarning(const char *msg,...)
Definition: qglobal.cpp:2954

◆ releaseKeyboard()

void QWidget::releaseKeyboard ( )

Releases the keyboard grab.

See also
grabKeyboard(), grabMouse(), releaseMouse()

Definition at line 3347 of file qwidget_mac.mm.

Referenced by QWidgetResizeHandler::eventFilter(), grabKeyboard(), isServerProcess(), QWidgetResizeHandler::keyPressEvent(), qstring_to_xtp(), and qt_grab_cursor().

3348 {
3349  if(!qt_nograb() && mac_keyboard_grabber == this)
3351 }
QWidget * mac_keyboard_grabber
Definition: qwidget_mac.mm:157
bool qt_nograb()

◆ releaseMouse()

void QWidget::releaseMouse ( )

Releases the mouse grab.

See also
grabMouse(), grabKeyboard(), releaseKeyboard()

Definition at line 3330 of file qwidget_mac.mm.

Referenced by QWidgetResizeHandler::eventFilter(), grabMouse(), isServerProcess(), QWidgetResizeHandler::keyPressEvent(), QVistaHelper::mouseReleaseEvent(), qJournalRecordProc(), qstring_to_xtp(), and qt_grab_cursor().

3331 {
3332  if(!qt_nograb() && mac_mouse_grabber == this) {
3333  mac_mouse_grabber = 0;
3335  }
3336 }
QWidget * mac_mouse_grabber
Definition: qwidget_mac.mm:156
bool qt_nograb()
void qt_mac_setMouseGrabCursor(bool set, QCursor *cursor=0)
Definition: qcursor_mac.mm:227

◆ releaseShortcut()

void QWidget::releaseShortcut ( int  id)

Removes the shortcut with the given id from Qt's shortcut system.

The widget will no longer receive QEvent::Shortcut events for the shortcut's key sequence (unless it has other shortcuts with the same key sequence).

Warning
You should not normally need to use this function since Qt's shortcut system removes shortcuts automatically when their parent widget is destroyed. It is best to use QAction or QShortcut to handle shortcuts, since they are easier to use than this low-level function. Note also that this is an expensive operation.
See also
grabShortcut() setShortcutEnabled()

Definition at line 11771 of file qwidget.cpp.

Referenced by QTabBar::removeTab(), QLabel::setBuddy(), QAbstractButton::setShortcut(), QTabBar::setTabText(), and QGroupBox::setTitle().

11772 {
11773  Q_ASSERT(qApp);
11774  if (id)
11775  qApp->d_func()->shortcutMap.removeShortcut(id, this, 0);
11776 }
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define qApp

◆ removeAction()

void QWidget::removeAction ( QAction action)

Removes the action action from this widget's list of actions.

See also
insertAction(), actions(), insertAction()

Definition at line 3386 of file qwidget.cpp.

Referenced by QMenuBar::clear(), QToolBar::clear(), QMenu::clear(), QAbstractSpinBox::contextMenuEvent(), QDialogButtonBox::event(), QAbstractItemView::focusOutEvent(), insertAction(), QAbstractItemView::keyPressEvent(), QPushButton::setMenu(), QToolButton::setMenu(), QTornOffMenu::syncWithMenu(), QToolBarLayout::takeAt(), and QAction::~QAction().

3387 {
3388  if (!action)
3389  return;
3390 
3391  Q_D(QWidget);
3392 
3393  QActionPrivate *apriv = action->d_func();
3394  apriv->widgets.removeAll(this);
3395 
3396  if (d->actions.removeAll(action)) {
3398  QApplication::sendEvent(this, &e);
3399  }
3400 }
double d
Definition: qnumeric_p.h:62
QList< QWidget * > widgets
Definition: qaction_p.h:121
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
The QActionEvent class provides an event that is generated when a QAction is added, removed, or changed.
Definition: qevent.h:632
#define Q_D(Class)
Definition: qglobal.h:2482
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
int removeAll(const T &t)
Removes all occurrences of value in the list and returns the number of entries removed.
Definition: qlist.h:770

◆ render() [1/2]

void QWidget::render ( QPaintDevice target,
const QPoint targetOffset = QPoint(),
const QRegion sourceRegion = QRegion(),
RenderFlags  renderFlags = RenderFlags(DrawWindowBackground | DrawChildren) 
)

Renders the sourceRegion of this widget into the target using renderFlags to determine how to render.

Since
4.3

Rendering starts at targetOffset in the target. For example:

QPixmap pixmap(widget->size());
widget->render(&pixmap);

If sourceRegion is a null region, this function will use QWidget::rect() as the region, i.e. the entire widget.

Ensure that you call QPainter::end() for the target device's active painter (if any) before rendering. For example:

QPainter painter(this);
...
painter.end();
myWidget->render(this);
Note
To obtain the contents of an OpenGL widget, use QGLWidget::grabFrameBuffer() or QGLWidget::renderPixmap() instead.

Definition at line 5372 of file qwidget.cpp.

Referenced by QPixmap::grabWidget(), render(), and QTreeViewPrivate::renderTreeToPixmapForAnimation().

5374 {
5375  d_func()->render(target, targetOffset, sourceRegion, renderFlags, false);
5376 }

◆ render() [2/2]

void QWidget::render ( QPainter painter,
const QPoint targetOffset = QPoint(),
const QRegion sourceRegion = QRegion(),
RenderFlags  renderFlags = RenderFlags(DrawWindowBackground | DrawChildren) 
)

Renders the widget into the painter's QPainter::device().

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Transformations and settings applied to the painter will be used when rendering.

Note
The painter must be active. On Mac OS X the widget will be rendered into a QPixmap and then drawn by the painter.
See also
QPainter::device()

Definition at line 5394 of file qwidget.cpp.

5396 {
5397  if (!painter) {
5398  qWarning("QWidget::render: Null pointer to painter");
5399  return;
5400  }
5401 
5402  if (!painter->isActive()) {
5403  qWarning("QWidget::render: Cannot render with an inactive painter");
5404  return;
5405  }
5406 
5407  const qreal opacity = painter->opacity();
5408  if (qFuzzyIsNull(opacity))
5409  return; // Fully transparent.
5410 
5411  Q_D(QWidget);
5412  const bool inRenderWithPainter = d->extra && d->extra->inRenderWithPainter;
5413  const QRegion toBePainted = !inRenderWithPainter ? d->prepareToRender(sourceRegion, renderFlags)
5414  : sourceRegion;
5415  if (toBePainted.isEmpty())
5416  return;
5417 
5418  if (!d->extra)
5419  d->createExtra();
5420  d->extra->inRenderWithPainter = true;
5421 
5422 #ifdef Q_WS_MAC
5423  d->render_helper(painter, targetOffset, toBePainted, renderFlags);
5424 #else
5425  QPaintEngine *engine = painter->paintEngine();
5426  Q_ASSERT(engine);
5427  QPaintEnginePrivate *enginePriv = engine->d_func();
5428  Q_ASSERT(enginePriv);
5429  QPaintDevice *target = engine->paintDevice();
5430  Q_ASSERT(target);
5431 
5432  // Render via a pixmap when dealing with non-opaque painters or printers.
5433  if (!inRenderWithPainter && (opacity < 1.0 || (target->devType() == QInternal::Printer))) {
5434  d->render_helper(painter, targetOffset, toBePainted, renderFlags);
5435  d->extra->inRenderWithPainter = false;
5436  return;
5437  }
5438 
5439  // Set new shared painter.
5440  QPainter *oldPainter = d->sharedPainter();
5441  d->setSharedPainter(painter);
5442 
5443  // Save current system clip, viewport and transform,
5444  const QTransform oldTransform = enginePriv->systemTransform;
5445  const QRegion oldSystemClip = enginePriv->systemClip;
5446  const QRegion oldSystemViewport = enginePriv->systemViewport;
5447 
5448  // This ensures that all painting triggered by render() is clipped to the current engine clip.
5449  if (painter->hasClipping()) {
5450  const QRegion painterClip = painter->deviceTransform().map(painter->clipRegion());
5451  enginePriv->setSystemViewport(oldSystemClip.isEmpty() ? painterClip : oldSystemClip & painterClip);
5452  } else {
5453  enginePriv->setSystemViewport(oldSystemClip);
5454  }
5455 
5456  render(target, targetOffset, toBePainted, renderFlags);
5457 
5458  // Restore system clip, viewport and transform.
5459  enginePriv->systemClip = oldSystemClip;
5460  enginePriv->setSystemViewport(oldSystemViewport);
5461  enginePriv->setSystemTransform(oldTransform);
5462 
5463  // Restore shared painter.
5464  d->setSharedPainter(oldPainter);
5465 #endif
5466 
5467  d->extra->inRenderWithPainter = false;
5468 }
void setSystemViewport(const QRegion &region)
The QPainter class performs low-level painting on widgets and other paint devices.
Definition: qpainter.h:86
double d
Definition: qnumeric_p.h:62
double qreal
Definition: qglobal.h:1193
qreal opacity() const
Returns the opacity of the painter.
Definition: qpainter.cpp:2115
QPaintDevice * paintDevice() const
Returns the device that this engine is painting on, if painting is active; otherwise returns 0...
void setSystemTransform(const QTransform &xform)
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define Q_D(Class)
Definition: qglobal.h:2482
virtual int devType() const
Definition: qpaintdevice.h:167
QRegion clipRegion() const
Returns the currently set clip region.
Definition: qpainter.cpp:2562
bool hasClipping() const
Returns true if clipping has been set; otherwise returns false.
Definition: qpainter.cpp:2499
bool isEmpty() const
Returns true if the region is empty; otherwise returns false.
Definition: qregion.cpp:4098
bool isActive() const
Returns true if begin() has been called and end() has not yet been called; otherwise returns false...
Definition: qpainter.cpp:1545
Q_CORE_EXPORT void qWarning(const char *,...)
QPoint map(const QPoint &p) const
Creates and returns a QPoint object that is a copy of the given point, mapped into the coordinate sys...
const QTransform & deviceTransform() const
Returns the matrix that transforms from logical coordinates to device coordinates of the platform dep...
Definition: qpainter.cpp:9579
QPaintEngine * paintEngine() const
Returns the paint engine that the painter is currently operating on if the painter is active; otherwi...
Definition: qpainter.cpp:1991
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
QTransform systemTransform
The QPaintEngine class provides an abstract definition of how QPainter draws to a given device on a g...
Definition: qpaintengine.h:90
static Q_DECL_CONSTEXPR bool qFuzzyIsNull(double d)
Definition: qglobal.h:2043
void render(QPaintDevice *target, const QPoint &targetOffset=QPoint(), const QRegion &sourceRegion=QRegion(), RenderFlags renderFlags=RenderFlags(DrawWindowBackground|DrawChildren))
Renders the sourceRegion of this widget into the target using renderFlags to determine how to render...
Definition: qwidget.cpp:5372
The QTransform class specifies 2D transformations of a coordinate system.
Definition: qtransform.h:65

◆ repaint [1/4]

void QWidget::repaint ( )
slot

Repaints the widget directly by calling paintEvent() immediately, unless updates are disabled or the widget is hidden.

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 call repaint() in a function which may itself be called from paintEvent(), you may get infinite recursion. The update() function never causes recursion.
See also
update(), paintEvent(), setUpdatesEnabled()

Definition at line 10761 of file qwidget.cpp.

Referenced by QAbstractButton::animateClick(), QColorShowLabel::dropEvent(), QStatusBar::hideOrShow(), QAbstractButton::keyPressEvent(), QScrollBar::mouseMoveEvent(), QAbstractButton::mouseMoveEvent(), QScrollBar::mousePressEvent(), QAbstractButton::mousePressEvent(), QTabBar::mousePressEvent(), qt_event_request_showsheet(), QAlphaWidget::render(), QSplashScreen::repaint(), repaint(), QProgressBar::reset(), QRollEffect::scroll(), QProgressBar::setAlignment(), QColorPicker::setCol(), QColorLuminancePicker::setCol(), setDisabledStyle(), QProgressBar::setTextVisible(), QColorLuminancePicker::setVal(), QProgressBar::setValue(), QColorShower::showCurrentColor(), and QToolButton::showMenu().

10762 {
10763  repaint(rect());
10764 }
QRect rect() const
void repaint()
Repaints the widget directly by calling paintEvent() immediately, unless updates are disabled or the ...
Definition: qwidget.cpp:10761

◆ repaint() [2/4]

void QWidget::repaint ( int  x,
int  y,
int  w,
int  h 
)

This version repaints a rectangle (x, y, w, h) inside the widget.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

If w is negative, it is replaced with width() - x, and if h is negative, it is replaced width height() - y.

Definition at line 10777 of file qwidget.cpp.

10778 {
10779  if (x > data->crect.width() || y > data->crect.height())
10780  return;
10781 
10782  if (w < 0)
10783  w = data->crect.width() - x;
10784  if (h < 0)
10785  h = data->crect.height() - y;
10786 
10787  repaint(QRect(x, y, w, h));
10788 }
int y() const
QRect crect
Definition: qwidget.h:131
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
QWidgetData * data
Definition: qwidget.h:815
void repaint()
Repaints the widget directly by calling paintEvent() immediately, unless updates are disabled or the ...
Definition: qwidget.cpp:10761
int x() const
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58

◆ repaint() [3/4]

void QWidget::repaint ( const QRect rect)

This version repaints a rectangle rect inside the widget.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 10797 of file qwidget.cpp.

10798 {
10799  Q_D(QWidget);
10800 
10802  update(rect);
10803  return;
10804  }
10805 
10806  if (!isVisible() || !updatesEnabled() || rect.isEmpty())
10807  return;
10808 
10809  if (hasBackingStoreSupport()) {
10810 #ifdef QT_MAC_USE_COCOA
10811  if (qt_widget_private(this)->isInUnifiedToolbar) {
10812  qt_widget_private(this)->unifiedSurface->renderToolbar(this, true);
10813  return;
10814  }
10815 #endif // QT_MAC_USE_COCOA
10816  QTLWExtra *tlwExtra = window()->d_func()->maybeTopData();
10817  if (tlwExtra && !tlwExtra->inTopLevelResize && tlwExtra->backingStore) {
10818  tlwExtra->inRepaint = true;
10819  tlwExtra->backingStore->markDirty(rect, this, true);
10820  tlwExtra->inRepaint = false;
10821  }
10822  } else {
10823  d->repaint_sys(rect);
10824  }
10825 }
double d
Definition: qnumeric_p.h:62
static bool hasBackingStoreSupport()
Definition: qwidget.cpp:169
bool isVisible() const
Definition: qwidget.h:1005
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
uint inTopLevelResize
Definition: qwidget_p.h:188
bool updatesEnabled() const
#define Q_D(Class)
Definition: qglobal.h:2482
void update()
Updates the widget unless updates are disabled or the widget is hidden.
Definition: qwidget.cpp:10883
void markDirty(const QRegion &rgn, QWidget *widget, bool updateImmediately=false, bool invalidateBuffer=false)
Marks the region of the widget as dirty (if not already marked as dirty) and posts an UpdateRequest e...
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
uint inRepaint
Definition: qwidget_p.h:189
bool isEmpty() const
Returns true if the rectangle is empty, otherwise returns false.
Definition: qrect.h:234
QWidget * window() const
Returns the window for this widget, i.e.
Definition: qwidget.cpp:4492
friend Q_GUI_EXPORT QWidgetPrivate * qt_widget_private(QWidget *widget)
Definition: qwidget.cpp:12920
QWidgetBackingStoreTracker backingStore
Definition: qwidget_p.h:166

◆ repaint() [4/4]

void QWidget::repaint ( const QRegion rgn)

This version repaints a region rgn inside the widget.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 10835 of file qwidget.cpp.

10836 {
10837  Q_D(QWidget);
10838 
10840  update(rgn);
10841  return;
10842  }
10843 
10844  if (!isVisible() || !updatesEnabled() || rgn.isEmpty())
10845  return;
10846 
10847  if (hasBackingStoreSupport()) {
10848 #ifdef QT_MAC_USE_COCOA
10849  if (qt_widget_private(this)->isInUnifiedToolbar) {
10850  qt_widget_private(this)->unifiedSurface->renderToolbar(this, true);
10851  return;
10852  }
10853 #endif // QT_MAC_USE_COCOA
10854  QTLWExtra *tlwExtra = window()->d_func()->maybeTopData();
10855  if (tlwExtra && !tlwExtra->inTopLevelResize && tlwExtra->backingStore) {
10856  tlwExtra->inRepaint = true;
10857  tlwExtra->backingStore->markDirty(rgn, this, true);
10858  tlwExtra->inRepaint = false;
10859  }
10860  } else {
10861  d->repaint_sys(rgn);
10862  }
10863 }
double d
Definition: qnumeric_p.h:62
static bool hasBackingStoreSupport()
Definition: qwidget.cpp:169
bool isVisible() const
Definition: qwidget.h:1005
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
uint inTopLevelResize
Definition: qwidget_p.h:188
bool updatesEnabled() const
#define Q_D(Class)
Definition: qglobal.h:2482
void update()
Updates the widget unless updates are disabled or the widget is hidden.
Definition: qwidget.cpp:10883
void markDirty(const QRegion &rgn, QWidget *widget, bool updateImmediately=false, bool invalidateBuffer=false)
Marks the region of the widget as dirty (if not already marked as dirty) and posts an UpdateRequest e...
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
bool isEmpty() const
Returns true if the region is empty; otherwise returns false.
Definition: qregion.cpp:4098
uint inRepaint
Definition: qwidget_p.h:189
QWidget * window() const
Returns the window for this widget, i.e.
Definition: qwidget.cpp:4492
friend Q_GUI_EXPORT QWidgetPrivate * qt_widget_private(QWidget *widget)
Definition: qwidget.cpp:12920
QWidgetBackingStoreTracker backingStore
Definition: qwidget_p.h:166

◆ resetInputContext()

void QWidget::resetInputContext ( )
protected

This function can be called on the widget that currently has focus to reset the input method operating on it.

This function is providing for convenience, instead you should use QInputContext::reset() on the input context that was returned by inputContext().

See also
QInputContext, inputContext(), QInputContext::reset()

Definition at line 522 of file qwidget.cpp.

Referenced by QLineEdit::clear(), event(), QLineEdit::redo(), setShown(), and QLineEdit::undo().

523 {
524  if (!hasFocus())
525  return;
526 #ifndef QT_NO_IM
527  QInputContext *qic = this->inputContext();
528  if(qic)
529  qic->reset();
530 #endif // QT_NO_IM
531 }
bool hasFocus() const
Definition: qwidget.cpp:6583
QInputContext * inputContext()
This function returns the QInputContext for this widget.
Definition: qwidget.cpp:474
virtual void reset()=0
This function can be reimplemented in a subclass to reset the state of the input method.
The QInputContext class abstracts the input method dependent data and composing state.
Definition: qinputcontext.h:83

◆ resize() [1/2]

void QWidget::resize ( int  w,
int  h 
)
inline

This corresponds to resize(QSize(w, h)).

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 1014 of file qwidget.h.

Referenced by QMenu::actionEvent(), QAxClientSite::activateObject(), QMenuPrivate::QMacMenuPrivate::addAction(), adjustSize(), QMdiAreaPrivate::appendChild(), QMenuBar::changeEvent(), QMenu::changeEvent(), QWorkspaceChild::changeEvent(), CloseButton::CloseButton(), QMdiSubWindow::event(), QWorkspaceChild::eventFilter(), QWorkspaceChild::iconWidget(), QColumnViewGrip::moveGrip(), QtWndProc(), QWhatsThat::QWhatsThat(), qWinProcessConfigRequests(), QWorkspaceChild::QWorkspaceChild(), QRubberBand::resize(), QColumnViewPreviewColumn::resizeEvent(), QMdiArea::resizeEvent(), QWorkspaceChild::resizeEvent(), QExpandingLineEdit::resizeToContents(), QMdiAreaPrivate::resizeToMinimumTileSize(), restoreGeometry(), QDockAreaLayoutInfo::restoreState(), QTipLabel::reuseTip(), QAlphaWidget::run(), QRollEffect::run(), QRollEffect::scroll(), QProgressDialog::setBar(), QProgressDialog::setCancelButton(), QProgressDialog::setCancelButtonText(), setFixedSize(), QProgressDialog::setLabel(), QProgressDialog::setLabelText(), setMaximumSize(), setMinimumSize(), QSplashScreen::setPixmap(), QShapedPixmapWidget::setPixmap(), QDeclarativeView::setRootObject(), QMenu::setTearOffEnabled(), QProgressDialog::setValue(), QScrollArea::setWidget(), QGLGlobalShareWidget::shareWidget(), QMdiSubWindow::showEvent(), QProgressDialog::showEvent(), QMdiArea::showEvent(), QDialog::showExtension(), QMdiSubWindow::showShaded(), QWorkspaceChild::showShaded(), and QScrollAreaPrivate::updateScrollBars().

1015 { resize(QSize(w, h)); }
void resize(int w, int h)
This corresponds to resize(QSize(w, h)).
Definition: qwidget.h:1014
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53

◆ resize() [2/2]

void QWidget::resize ( const QSize s)

Definition at line 7200 of file qwidget.cpp.

7201 {
7202  Q_D(QWidget);
7205  d->setGeometry_sys(geometry().x(), geometry().y(), s.width(), s.height(), false);
7206  d->setDirtyOpaqueRegion();
7207  } else {
7210  }
7211 }
double d
Definition: qnumeric_p.h:62
int y() const
QRect crect
Definition: qwidget.h:131
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
QSize expandedTo(const QSize &) const
Returns a size holding the maximum width and height of this size and the given otherSize.
Definition: qsize.h:187
#define Q_D(Class)
Definition: qglobal.h:2482
QSize boundedTo(const QSize &) const
Returns a size holding the minimum width and height of this size and the given otherSize.
Definition: qsize.h:192
int width() const
Returns the width.
Definition: qsize.h:126
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
QWidgetData * data
Definition: qwidget.h:815
void setSize(const QSize &s)
Sets the size of the rectangle to the given size.
Definition: qrect.h:448
int x() const
QSize maximumSize() const
int height() const
Returns the height.
Definition: qsize.h:129
QSize minimumSize() const
void setAttribute(Qt::WidgetAttribute, bool on=true)
Sets the attribute attribute on this widget if on is true; otherwise clears the attribute.
Definition: qwidget.cpp:11087
const QRect & geometry() const

◆ resizeEvent()

void QWidget::resizeEvent ( QResizeEvent )
protectedvirtual

This event handler can be reimplemented in a subclass to receive widget resize events which are passed in the event parameter.

When resizeEvent() is called, the widget already has its new geometry. The old size is accessible through QResizeEvent::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.

See also
moveEvent(), event(), resize(), QResizeEvent, paintEvent(), {Scribble Example}

Reimplemented in QWorkspaceChild, QColorPicker, QGLWidget, QAbstractItemView, QMessageBox, QTextEdit, QGraphicsView, QComboBoxPrivateContainer, QComboBox, QPlainTextEdit, QWizard, QTabBar, QSplitterHandle, QSystemTrayIconSys, QTabWidget, QListView, QMdiArea, QCalendarWidget, QToolBar, QTipLabel, QMenuBar, QAbstractSpinBox, QAxHostWidget, QProgressDialog, QMdiSubWindow, QSplitter, QX11EmbedContainer, QDialog, QBalloonTip, QWorkspace, QDeclarativeView, QAbstractScrollArea, QStatusBar, QColumnView, QGroupBox, QScriptEdit, QDesktopWidget, QComboBoxListView, QDial, QAxWidget, QScrollArea, QRubberBand, QColumnViewPreviewColumn, QX11EmbedWidget, and QWSEmbedWidget.

Definition at line 9587 of file qwidget.cpp.

Referenced by QComboBox::addItems(), QDesktopWidget::availableGeometry(), QGLWidget::event(), event(), QDesktopWidgetPrivate::init(), QToolBar::isAreaAllowed(), QCalendarWidget::isNavigationBarVisible(), QRubberBand::resize(), QX11EmbedWidget::resizeEvent(), QDial::resizeEvent(), QGroupBox::resizeEvent(), QStatusBar::resizeEvent(), QBalloonTip::resizeEvent(), QMdiSubWindow::resizeEvent(), QAbstractSpinBox::resizeEvent(), QTipLabel::resizeEvent(), QToolBar::resizeEvent(), QCalendarWidget::resizeEvent(), QTabWidget::resizeEvent(), QSystemTrayIconSys::resizeEvent(), QSplitterHandle::resizeEvent(), QComboBoxPrivateContainer::resizeEvent(), QColorPicker::resizeEvent(), and setShown().

9588 {
9589 }

◆ restoreGeometry()

bool QWidget::restoreGeometry ( const QByteArray geometry)

Restores the geometry and state top-level widgets stored in the byte array geometry.

Since
4.2

Returns true on success; otherwise returns false.

If the restored geometry is off-screen, it will be modified to be inside the available screen geometry.

To restore geometry saved using QSettings, you can use code like this:

QSettings settings("MyCompany", "MyApp");
myWidget->restoreGeometry(settings.value("myWidget/geometry").toByteArray());

See the Window Geometry documentation for an overview of geometry issues with windows.

Use QMainWindow::restoreState() to restore the geometry and the state of toolbars and dock widgets.

See also
saveGeometry(), QSettings, QMainWindow::saveState(), QMainWindow::restoreState()

Definition at line 7313 of file qwidget.cpp.

Referenced by QScriptEngineDebugger::standardWindow().

7314 {
7315  if (geometry.size() < 4)
7316  return false;
7317  QDataStream stream(geometry);
7318  stream.setVersion(QDataStream::Qt_4_0);
7319 
7320  const quint32 magicNumber = 0x1D9D0CB;
7321  quint32 storedMagicNumber;
7322  stream >> storedMagicNumber;
7323  if (storedMagicNumber != magicNumber)
7324  return false;
7325 
7326  const quint16 currentMajorVersion = 1;
7327  quint16 majorVersion = 0;
7328  quint16 minorVersion = 0;
7329 
7330  stream >> majorVersion >> minorVersion;
7331 
7332  if (majorVersion != currentMajorVersion)
7333  return false;
7334  // (Allow all minor versions.)
7335 
7336  QRect restoredFrameGeometry;
7337  QRect restoredNormalGeometry;
7338  qint32 restoredScreenNumber;
7339  quint8 maximized;
7341 
7342  stream >> restoredFrameGeometry
7343  >> restoredNormalGeometry
7344  >> restoredScreenNumber
7345  >> maximized
7346  >> fullScreen;
7347 
7348  const int frameHeight = 20;
7349  if (!restoredFrameGeometry.isValid())
7350  restoredFrameGeometry = QRect(QPoint(0,0), sizeHint());
7351 
7352  if (!restoredNormalGeometry.isValid())
7353  restoredNormalGeometry = QRect(QPoint(0, frameHeight), sizeHint());
7354  if (!restoredNormalGeometry.isValid()) {
7355  // use the widget's adjustedSize if the sizeHint() doesn't help
7356  restoredNormalGeometry.setSize(restoredNormalGeometry
7357  .size()
7358  .expandedTo(d_func()->adjustedSize()));
7359  }
7360 
7361  const QDesktopWidget * const desktop = QApplication::desktop();
7362  if (restoredScreenNumber >= desktop->numScreens())
7363  restoredScreenNumber = desktop->primaryScreen();
7364 
7365  const QRect availableGeometry = desktop->availableGeometry(restoredScreenNumber);
7366 
7367  // Modify the restored geometry if we are about to restore to coordinates
7368  // that would make the window "lost". This happens if:
7369  // - The restored geometry is completely oustside the available geometry
7370  // - The title bar is outside the available geometry.
7371  // - (Mac only) The window is higher than the available geometry. It must
7372  // be possible to bring the size grip on screen by moving the window.
7373 #ifdef Q_WS_MAC
7374  restoredFrameGeometry.setHeight(qMin(restoredFrameGeometry.height(), availableGeometry.height()));
7375  restoredNormalGeometry.setHeight(qMin(restoredNormalGeometry.height(), availableGeometry.height() - frameHeight));
7376 #endif
7377 
7378  if (!restoredFrameGeometry.intersects(availableGeometry)) {
7379  restoredFrameGeometry.moveBottom(qMin(restoredFrameGeometry.bottom(), availableGeometry.bottom()));
7380  restoredFrameGeometry.moveLeft(qMax(restoredFrameGeometry.left(), availableGeometry.left()));
7381  restoredFrameGeometry.moveRight(qMin(restoredFrameGeometry.right(), availableGeometry.right()));
7382  }
7383  restoredFrameGeometry.moveTop(qMax(restoredFrameGeometry.top(), availableGeometry.top()));
7384 
7385  if (!restoredNormalGeometry.intersects(availableGeometry)) {
7386  restoredNormalGeometry.moveBottom(qMin(restoredNormalGeometry.bottom(), availableGeometry.bottom()));
7387  restoredNormalGeometry.moveLeft(qMax(restoredNormalGeometry.left(), availableGeometry.left()));
7388  restoredNormalGeometry.moveRight(qMin(restoredNormalGeometry.right(), availableGeometry.right()));
7389  }
7390  restoredNormalGeometry.moveTop(qMax(restoredNormalGeometry.top(), availableGeometry.top() + frameHeight));
7391 
7392  if (maximized || fullScreen) {
7393  // set geomerty before setting the window state to make
7394  // sure the window is maximized to the right screen.
7395  Qt::WindowStates ws = windowState();
7396 #ifndef Q_WS_WIN
7397  setGeometry(restoredNormalGeometry);
7398 #else
7399  if (ws & Qt::WindowFullScreen) {
7400  // Full screen is not a real window state on Windows.
7401  move(availableGeometry.topLeft());
7402  } else if (ws & Qt::WindowMaximized) {
7403  // Setting a geometry on an already maximized window causes this to be
7404  // restored into a broken, half-maximized state, non-resizable state (QTBUG-4397).
7405  // Move the window in normal state if needed.
7406  if (restoredScreenNumber != desktop->screenNumber(this)) {
7408  setGeometry(restoredNormalGeometry);
7409  }
7410  } else {
7411  setGeometry(restoredNormalGeometry);
7412  }
7413 #endif // Q_WS_WIN
7414  if (maximized)
7415  ws |= Qt::WindowMaximized;
7416  if (fullScreen)
7417  ws |= Qt::WindowFullScreen;
7418  setWindowState(ws);
7419  d_func()->topData()->normalGeometry = restoredNormalGeometry;
7420  } else {
7421  QPoint offset;
7422 #ifdef Q_WS_X11
7423  if (isFullScreen())
7424  offset = d_func()->topData()->fullScreenOffset;
7425 #endif
7426  setWindowState(windowState() & ~(Qt::WindowMaximized | Qt::WindowFullScreen));
7427  move(restoredFrameGeometry.topLeft() + offset);
7428  resize(restoredNormalGeometry.size());
7429  }
7430  return true;
7431 }
void setHeight(int h)
Sets the height of the rectangle to the given height.
Definition: qrect.h:445
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
int qint32
Definition: qglobal.h:937
Q_CORE_EXPORT QTextStream & ws(QTextStream &s)
QSize size() const
Qt::WindowStates windowState() const
Returns the current window state.
Definition: qwidget.cpp:3086
bool fullScreen
whether the widget is shown in full screen mode
Definition: qwidget.h:194
void setWindowState(Qt::WindowStates state)
Sets the window state to windowState.
void moveLeft(int pos)
Moves the rectangle horizontally, leaving the rectangle&#39;s left edge at the given x coordinate...
Definition: qrect.h:350
void moveRight(int pos)
Moves the rectangle horizontally, leaving the rectangle&#39;s right edge at the given x coordinate...
Definition: qrect.h:356
int left() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:240
unsigned char quint8
Definition: qglobal.h:934
void setGeometry(int x, int y, int w, int h)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qwidget.h:1017
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
int bottom() const
Returns the y-coordinate of the rectangle&#39;s bottom edge.
Definition: qrect.h:249
bool maximized
whether this widget is maximized
Definition: qwidget.h:193
void moveBottom(int pos)
Moves the rectangle vertically, leaving the rectangle&#39;s bottom edge at the given y coordinate...
Definition: qrect.h:362
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
virtual QSize sizeHint() const
static FILE * stream
QSize size() const
Returns the size of the rectangle.
Definition: qrect.h:309
unsigned short quint16
Definition: qglobal.h:936
void setSize(const QSize &s)
Sets the size of the rectangle to the given size.
Definition: qrect.h:448
int numScreens() const
static QDesktopWidget * desktop()
Returns the desktop widget (also called the root window).
int top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:243
int right() const
Returns the x-coordinate of the rectangle&#39;s right edge.
Definition: qrect.h:246
void resize(int w, int h)
This corresponds to resize(QSize(w, h)).
Definition: qwidget.h:1014
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
bool isFullScreen() const
Definition: qwidget.cpp:3153
unsigned int quint32
Definition: qglobal.h:938
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
int size() const
Returns the number of bytes in this byte array.
Definition: qbytearray.h:402
int screenNumber(const QWidget *widget=0) const
The QDataStream class provides serialization of binary data to a QIODevice.
Definition: qdatastream.h:71
bool intersects(const QRect &r) const
Returns true if this rectangle intersects with the given rectangle (i.
Definition: qrect.cpp:1429
const QRect availableGeometry(int screen=-1) const
void moveTop(int pos)
Moves the rectangle vertically, leaving the rectangle&#39;s top edge at the given y coordinate.
Definition: qrect.h:353
bool isValid() const
Returns true if the rectangle is valid, otherwise returns false.
Definition: qrect.h:237
void move(int x, int y)
This corresponds to move(QPoint(x, y)).
Definition: qwidget.h:1011
QPoint topLeft() const
Returns the position of the rectangle&#39;s top-left corner.
Definition: qrect.h:288

◆ saveGeometry()

QByteArray QWidget::saveGeometry ( ) const

Saves the current geometry and state for top-level widgets.

Since
4.2

To save the geometry when the window closes, you can implement a close event like this:

void MyWidget::closeEvent(QCloseEvent *event)
{
QSettings settings("MyCompany", "MyApp");
settings.setValue("geometry", saveGeometry());
}

See the Window Geometry documentation for an overview of geometry issues with windows.

Use QMainWindow::saveState() to save the geometry and the state of toolbars and dock widgets.

See also
restoreGeometry(), QMainWindow::saveState(), QMainWindow::restoreState()

Definition at line 7251 of file qwidget.cpp.

7252 {
7253 #ifdef QT_MAC_USE_COCOA
7254  // We check if the window was maximized during this invocation. If so, we need to record the
7255  // starting position as 0,0.
7256  Q_D(const QWidget);
7257  QRect newFramePosition = frameGeometry();
7258  QRect newNormalPosition = normalGeometry();
7259  if(d->topData()->wasMaximized && !(windowState() & Qt::WindowMaximized)) {
7260  // Change the starting position
7261  newFramePosition.moveTo(0, 0);
7262  newNormalPosition.moveTo(0, 0);
7263  }
7264 #endif // QT_MAC_USE_COCOA
7265  QByteArray array;
7267  stream.setVersion(QDataStream::Qt_4_0);
7268  const quint32 magicNumber = 0x1D9D0CB;
7269  quint16 majorVersion = 1;
7270  quint16 minorVersion = 0;
7271  stream << magicNumber
7272  << majorVersion
7273  << minorVersion
7274 #ifdef QT_MAC_USE_COCOA
7275  << newFramePosition
7276  << newNormalPosition
7277 #else
7278  << frameGeometry()
7279  << normalGeometry()
7280 #endif // QT_MAC_USE_COCOA
7281  << qint32(QApplication::desktop()->screenNumber(this))
7284  return array;
7285 }
double d
Definition: qnumeric_p.h:62
int qint32
Definition: qglobal.h:937
Qt::WindowStates windowState() const
Returns the current window state.
Definition: qwidget.cpp:3086
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
void moveTo(int x, int t)
Moves the rectangle, leaving the top-left corner at the given position (x, y).
Definition: qrect.h:334
unsigned char quint8
Definition: qglobal.h:934
#define Q_D(Class)
Definition: qglobal.h:2482
static FILE * stream
unsigned short quint16
Definition: qglobal.h:936
static QDesktopWidget * desktop()
Returns the desktop widget (also called the root window).
QRect frameGeometry() const
unsigned int quint32
Definition: qglobal.h:938
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
The QDataStream class provides serialization of binary data to a QIODevice.
Definition: qdatastream.h:71
QRect normalGeometry() const

◆ scroll() [1/2]

void QWidget::scroll ( int  dx,
int  dy 
)

Scrolls the widget including its children dx pixels to the right and dy downward.

Both dx and dy may be negative.

After scrolling, the widgets will receive paint events for the areas that need to be repainted. For widgets that Qt knows to be opaque, this is only the newly exposed parts. For example, if an opaque widget is scrolled 8 pixels to the left, only an 8-pixel wide stripe at the right edge needs updating.

Since widgets propagate the contents of their parents by default, you need to set the autoFillBackground property, or use setAttribute() to set the Qt::WA_OpaquePaintEvent attribute, to make a widget opaque.

For widgets that use contents propagation, a scroll will cause an update of the entire scroll area.

See also
{Transparency and Double Buffering}

Definition at line 10684 of file qwidget.cpp.

Referenced by QMdiArea::scrollContentsBy(), QGraphicsView::scrollContentsBy(), and QScriptEdit::updateExtraArea().

10685 {
10686  if ((!updatesEnabled() && children().size() == 0) || !isVisible())
10687  return;
10688  if (dx == 0 && dy == 0)
10689  return;
10690  Q_D(QWidget);
10691 #ifndef QT_NO_GRAPHICSVIEW
10693  // Graphics View maintains its own dirty region as a list of rects;
10694  // until we can connect item updates directly to the view, we must
10695  // separately add a translated dirty region.
10696  if (!d->dirty.isEmpty()) {
10697  foreach (const QRect &rect, (d->dirty.translated(dx, dy)).rects())
10698  proxy->update(rect);
10699  }
10700  proxy->scroll(dx, dy, proxy->subWidgetRect(this));
10701  return;
10702  }
10703 #endif
10704  d->setDirtyOpaqueRegion();
10705  d->scroll_sys(dx, dy);
10706 }
double d
Definition: qnumeric_p.h:62
QSize size() const
bool isVisible() const
Definition: qwidget.h:1005
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
bool updatesEnabled() const
#define Q_D(Class)
Definition: qglobal.h:2482
QRect rect() const
The QGraphicsProxyWidget class provides a proxy layer for embedding a QWidget in a QGraphicsScene...
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
const QObjectList & children() const
Returns a list of child objects.
Definition: qobject.h:197
static QGraphicsProxyWidget * nearestGraphicsProxyWidget(const QWidget *origin)
Finds the nearest widget embedded in a graphics proxy widget along the chain formed by this widget an...
Definition: qwidget.cpp:6098

◆ scroll() [2/2]

void QWidget::scroll ( int  dx,
int  dy,
const QRect r 
)

This version only scrolls r and does not move the children of the widget.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

If r is empty or invalid, the result is undefined.

See also
QScrollArea

Definition at line 10721 of file qwidget.cpp.

10722 {
10723 
10724  if ((!updatesEnabled() && children().size() == 0) || !isVisible())
10725  return;
10726  if (dx == 0 && dy == 0)
10727  return;
10728  Q_D(QWidget);
10729 #ifndef QT_NO_GRAPHICSVIEW
10731  // Graphics View maintains its own dirty region as a list of rects;
10732  // until we can connect item updates directly to the view, we must
10733  // separately add a translated dirty region.
10734  if (!d->dirty.isEmpty()) {
10735  foreach (const QRect &rect, (d->dirty.translated(dx, dy) & r).rects())
10736  proxy->update(rect);
10737  }
10738  proxy->scroll(dx, dy, r.translated(proxy->subWidgetRect(this).topLeft().toPoint()));
10739  return;
10740  }
10741 #endif
10742  d->scroll_sys(dx, dy, r);
10743 }
double d
Definition: qnumeric_p.h:62
QSize size() const
bool isVisible() const
Definition: qwidget.h:1005
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
QRect translated(int dx, int dy) const
Returns a copy of the rectangle that is translated dx along the x axis and dy along the y axis...
Definition: qrect.h:328
bool updatesEnabled() const
#define Q_D(Class)
Definition: qglobal.h:2482
QRect rect() const
The QGraphicsProxyWidget class provides a proxy layer for embedding a QWidget in a QGraphicsScene...
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
const QObjectList & children() const
Returns a list of child objects.
Definition: qobject.h:197
static QGraphicsProxyWidget * nearestGraphicsProxyWidget(const QWidget *origin)
Finds the nearest widget embedded in a graphics proxy widget along the chain formed by this widget an...
Definition: qwidget.cpp:6098

◆ setAcceptDrops()

void QWidget::setAcceptDrops ( bool  on)

Definition at line 3534 of file qwidget.cpp.

Referenced by QColorShowLabel::QColorShowLabel(), QGraphicsView::QGraphicsView(), QX11EmbedContainer::QX11EmbedContainer(), QAbstractItemView::setDragDropMode(), QGraphicsView::setupViewport(), and QListView::setViewMode().

3535 {
3537 
3538 }
void setAttribute(Qt::WidgetAttribute, bool on=true)
Sets the attribute attribute on this widget if on is true; otherwise clears the attribute.
Definition: qwidget.cpp:11087

◆ setAccessibleDescription()

void QWidget::setAccessibleDescription ( const QString description)

Definition at line 11709 of file qwidget.cpp.

11710 {
11711  Q_D(QWidget);
11712  d->accessibleDescription = description;
11714 }
double d
Definition: qnumeric_p.h:62
static void updateAccessibility(QObject *, int who, Event reason)
Notifies accessibility clients about a change in object&#39;s accessibility information.
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_D(Class)
Definition: qglobal.h:2482

◆ setAccessibleName()

void QWidget::setAccessibleName ( const QString name)

Definition at line 11684 of file qwidget.cpp.

11685 {
11686  Q_D(QWidget);
11687  d->accessibleName = name;
11689 }
double d
Definition: qnumeric_p.h:62
static void updateAccessibility(QObject *, int who, Event reason)
Notifies accessibility clients about a change in object&#39;s accessibility information.
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_D(Class)
Definition: qglobal.h:2482
const char * name

◆ setAttribute()

void QWidget::setAttribute ( Qt::WidgetAttribute  attribute,
bool  on = true 
)

Sets the attribute attribute on this widget if on is true; otherwise clears the attribute.

See also
testAttribute()

Definition at line 11087 of file qwidget.cpp.

Referenced by QGroupBoxPrivate::_q_setChildrenEnabled(), QMessageBox::about(), QMessageBox::aboutQt(), QMenu::actionEvent(), QWidgetPrivate::activateChildLayoutsRecursively(), QMenuPrivate::QMacMenuPrivate::addAction(), QLayout::addChildWidget(), QMdiArea::addSubWindow(), QGroupBox::childEvent(), QMessageBoxDetailsText::TextEdit::contextMenuEvent(), QLabel::contextMenuEvent(), QTextControlPrivate::contextMenuEvent(), QMainWindow::contextMenuEvent(), create(), QToolBarLayout::createItem(), PvrEglScreenSurfaceFunctions::createNativeWindow(), QWidgetPrivate::createWinId(), destroy(), do_size_hints(), QGraphicsScenePrivate::enableTouchEventsOnViews(), QDialog::event(), QMdiSubWindow::event(), QAbstractButton::event(), QLabel::event(), event(), QSizeGrip::eventFilter(), QDialog::exec(), QAbstractItemView::focusInEvent(), QApplicationPrivate::focusNextPrevChild_helper(), QMainWindowLayout::getSeparatorWidget(), grabShortcut(), QWidgetPrivate::hideChildren(), QStatusBar::hideOrShow(), QColumnView::initializeColumn(), make_widget_eventUPP(), QCalendarWidget::mousePressEvent(), QMenu::mousePressEvent(), QCalendarPopup::mousePressEvent(), QComboBoxPrivateContainer::mousePressEvent(), move(), nativeParentWidget(), QApplication::notify(), QApplicationPrivate::notify_helper(), QDialog::open(), QGtkStylePrivate::openDirectory(), QGtkStylePrivate::openFilename(), QGtkStylePrivate::openFilenames(), QPrintDialogPrivate::openWindowsPrintDialogModally(), QWindowsXPStyle::polish(), QMacStyle::polish(), QWindowsVistaStyle::polish(), QPlastiqueStyle::polish(), QCleanlooksStyle::polish(), QStyleSheetStyle::polish(), QGtkStyle::polish(), QMenu::popup(), QAlphaWidget::QAlphaWidget(), QAxHostWidget::QAxHostWidget(), QBalloonTip::QBalloonTip(), QCalendarPopup::QCalendarPopup(), QColorPicker::QColorPicker(), QComboBoxPrivateContainer::QComboBoxPrivateContainer(), QComboBoxPrivateScroller::QComboBoxPrivateScroller(), QDesktopWidget::QDesktopWidget(), QDialog::QDialog(), QFocusFrame::QFocusFrame(), QGLOverlayWidget::QGLOverlayWidget(), QGraphicsView::QGraphicsView(), QListView::QListView(), QMacCocoaViewContainer::QMacCocoaViewContainer(), QMacNativeWidget::QMacNativeWidget(), QMdiSubWindow::QMdiSubWindow(), QPageSetupWidget::QPageSetupWidget(), qPRCleanup(), qPRCreate(), QRollEffect::QRollEffect(), QRubberBand::QRubberBand(), QShapedPixmapWidget::QShapedPixmapWidget(), qt_mac_unregister_widget(), qt_win_get_existing_directory(), qt_win_get_open_file_name(), qt_win_get_open_file_names(), qt_win_get_save_file_name(), QTornOffMenu::QTornOffMenu(), QWhatsThat::QWhatsThat(), QWorkspaceChild::QWorkspaceChild(), QX11EmbedContainer::QX11EmbedContainer(), QX11EmbedWidget::QX11EmbedWidget(), QAlphaWidget::render(), resize(), QSplitterHandle::resizeEvent(), QAlphaWidget::run(), QRollEffect::run(), QGtkStylePrivate::saveFilename(), QRollEffect::scroll(), setAcceptDrops(), setAttribute(), QWorkspace::setBackground(), QDateTimeEdit::setCalendarPopup(), setContentsMargins(), setCursor(), QComboBox::setEditable(), setEnabled(), QDockWidget::setFloating(), QMacStyle::setFocusRectPolicy(), QApplicationPrivate::setFocusWidget(), setFont(), QFrame::setFrameStyle(), setGeometry(), QComboBoxPrivateContainer::setItemView(), setLayoutDirection(), QComboBox::setLineEdit(), setLocale(), setMaximumSize(), setMinimumSize(), QDialog::setModal(), QSplitter::setOrientation(), QProgressBar::setOrientation(), QAbstractSlider::setOrientation(), setPalette(), setParent(), QWidgetPrivate::setParent_sys(), QSplashScreen::setPixmap(), QPlainTextEdit::setReadOnly(), QLineEdit::setReadOnly(), QTextEdit::setReadOnly(), QDeclarativeView::setRootObject(), setSizePolicy(), setStyle(), setUpdatesEnabled(), QMdiArea::setupViewport(), QGraphicsView::setupViewport(), QDialog::setVisible(), QColorDialog::setVisible(), QFontDialog::setVisible(), setVisible(), QMdiSubWindow::setWidget(), QGraphicsProxyWidgetPrivate::setWidget_helper(), QMacStyle::setWidgetSizePolicy(), setWindowIcon(), setWindowModality(), setWindowModified(), setWindowOpacity(), QWidgetPrivate::showChildren(), QDialog::showEvent(), QWidgetBackingStore::showYellowThing(), QSystemTrayIconSys::sysTrayTracker(), QAxServerBase::TranslateAcceleratorW(), QApplicationPrivate::translateRawTouchEvent(), QStatusBarPrivate::tryToShowSizeGrip(), QWindowsXPStyle::unpolish(), QMacStyle::unpolish(), QWindowsVistaStyle::unpolish(), QPlastiqueStyle::unpolish(), QCleanlooksStyle::unpolish(), QStyleSheetStyle::unpolish(), unsetCursor(), unsetLayoutDirection(), unsetLocale(), winId(), and QApplication::x11ProcessEvent().

11088 {
11089  if (testAttribute(attribute) == on)
11090  return;
11091 
11092  Q_D(QWidget);
11093  Q_ASSERT_X(sizeof(d->high_attributes)*8 >= (Qt::WA_AttributeCount - sizeof(uint)*8),
11094  "QWidget::setAttribute(WidgetAttribute, bool)",
11095  "QWidgetPrivate::high_attributes[] too small to contain all attributes in WidgetAttribute");
11096 #ifdef Q_WS_WIN
11097  // ### Don't use PaintOnScreen+paintEngine() to do native painting in 5.0
11098  if (attribute == Qt::WA_PaintOnScreen && on && !inherits("QGLWidget")) {
11099  // see qwidget_win.cpp, ::paintEngine for details
11100  paintEngine();
11101  if (d->noPaintOnScreen)
11102  return;
11103  }
11104 #endif
11105 
11106  setAttribute_internal(attribute, on, data, d);
11107 
11108  switch (attribute) {
11109 
11110 #ifndef QT_NO_DRAGANDDROP
11111  case Qt::WA_AcceptDrops: {
11114  else if (!on && (isWindow() || !parentWidget() || !parentWidget()->testAttribute(Qt::WA_DropSiteRegistered)))
11117  QApplication::sendEvent(this, &e);
11118  break;
11119  }
11121  d->registerDropSite(on);
11122  for (int i = 0; i < d->children.size(); ++i) {
11123  QWidget *w = qobject_cast<QWidget *>(d->children.at(i));
11126  }
11127  break;
11128  }
11129 #endif
11130 
11132  d->sendChildEvents = !on;
11133  break;
11135  d->receiveChildEvents = !on;
11136  break;
11138 #ifdef Q_WS_MAC
11139  d->setStyle_helper(style(), false, true); // Make sure things get unpolished/polished correctly.
11140  // fall through since changing the metal attribute affects the opaque size grip.
11142  d->macUpdateOpaqueSizeGrip();
11143  break;
11145  if (hasFocus()) {
11146  clearFocus();
11147  setFocus();
11148  }
11149  break;
11150  case Qt::WA_Hover:
11152  break;
11153 #endif
11155 #ifdef Q_WS_MAC
11156  d->macUpdateHideOnSuspend();
11157 #endif
11158  break;
11159  case Qt::WA_MacNormalSize:
11160  case Qt::WA_MacSmallSize:
11161  case Qt::WA_MacMiniSize:
11162 #ifdef Q_WS_MAC
11163  {
11164  // We can only have one of these set at a time
11167  for (int i = 0; i < 3; ++i) {
11168  if (MacSizes[i] != attribute)
11169  setAttribute_internal(MacSizes[i], false, data, d);
11170  }
11171  d->macUpdateSizeAttribute();
11172  }
11173 #endif
11174  break;
11175  case Qt::WA_ShowModal:
11176  if (!on) {
11177  if (isVisible())
11179  // reset modality type to Modeless when clearing WA_ShowModal
11181  } else if (data->window_modality == Qt::NonModal) {
11182  // determine the modality type if it hasn't been set prior
11183  // to setting WA_ShowModal. set the default to WindowModal
11184  // if we are the child of a group leader; otherwise use
11185  // ApplicationModal.
11186  QWidget *w = parentWidget();
11187  if (w)
11188  w = w->window();
11189  while (w && !w->testAttribute(Qt::WA_GroupLeader)) {
11190  w = w->parentWidget();
11191  if (w)
11192  w = w->window();
11193  }
11195  ? Qt::WindowModal
11197  // Some window managers does not allow us to enter modal after the
11198  // window is showing. Therefore, to be consistent, we cannot call
11199  // QApplicationPrivate::enterModal(this) here. The window must be
11200  // hidden before changing modality.
11201  }
11203  // don't call setModal_sys() before create_sys()
11204  d->setModal_sys();
11205  }
11206  break;
11207  case Qt::WA_MouseTracking: {
11209  QApplication::sendEvent(this, &e);
11210  break; }
11211  case Qt::WA_NativeWindow: {
11212 #ifndef QT_NO_IM
11213  QWidget *focusWidget = d->effectiveFocusWidget();
11214  QInputContext *ic = 0;
11215  if (on && !internalWinId() && hasFocus()
11216  && focusWidget->testAttribute(Qt::WA_InputMethodEnabled)) {
11217  ic = focusWidget->d_func()->inputContext();
11218  if (ic) {
11219  ic->reset();
11220  ic->setFocusWidget(0);
11221  }
11222  }
11223  if (!qApp->testAttribute(Qt::AA_DontCreateNativeWidgetSiblings) && parentWidget()
11224 #if defined(Q_WS_MAC) && defined(QT_MAC_USE_COCOA)
11225  // On Mac, toolbars inside the unified title bar will never overlap with
11226  // siblings in the content view. So we skip enforce native siblings in that case
11227  && !d->isInUnifiedToolbar && parentWidget()->isWindow()
11228 #endif // Q_WS_MAC && QT_MAC_USE_COCOA
11229  )
11230  parentWidget()->d_func()->enforceNativeChildren();
11232  d->createWinId();
11233  if (ic && isEnabled() && focusWidget->isEnabled()
11234  && focusWidget->testAttribute(Qt::WA_InputMethodEnabled)) {
11235  ic->setFocusWidget(focusWidget);
11236  }
11237 #endif //QT_NO_IM
11238  break;
11239  }
11240  case Qt::WA_PaintOnScreen:
11241  d->updateIsOpaque();
11242 #if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_OS_SYMBIAN)
11243  // Recreate the widget if it's already created as an alien widget and
11244  // WA_PaintOnScreen is enabled. Paint on screen widgets must have win id.
11245  // So must their children.
11246  if (on) {
11248  d->enforceNativeChildren();
11249  }
11250 #endif
11251  // fall through
11253  d->updateIsOpaque();
11254  break;
11256  d->updateIsOpaque();
11257  // fall through...
11259  d->updateSystemBackground();
11260  break;
11262 #ifdef Q_WS_MAC
11263  d->macUpdateIgnoreMouseEvents();
11264 #endif
11265  break;
11267 #ifndef QT_NO_IM
11268  QWidget *focusWidget = d->effectiveFocusWidget();
11269  QInputContext *ic = focusWidget->d_func()->assignedInputContext();
11270  if (!ic && (!on || hasFocus()))
11271  ic = focusWidget->d_func()->inputContext();
11272  if (ic) {
11273  if (on && hasFocus() && ic->focusWidget() != focusWidget && isEnabled()
11274  && focusWidget->testAttribute(Qt::WA_InputMethodEnabled)) {
11275  ic->setFocusWidget(focusWidget);
11276  } else if (!on && ic->focusWidget() == focusWidget) {
11277  ic->reset();
11278  ic->setFocusWidget(0);
11279  }
11280  }
11281 #endif //QT_NO_IM
11282  break;
11283  }
11285  d->resolvePalette();
11286  d->resolveFont();
11287  d->resolveLocale();
11288  break;
11289 #ifdef Q_WS_X11
11291  if (!d->extra)
11292  d->createExtra();
11293  d->extra->compress_events = on;
11294  break;
11296  d->updateIsOpaque();
11297  break;
11300  d->updateX11AcceptFocus();
11301  break;
11302 #endif
11303  case Qt::WA_DontShowOnScreen: {
11304  if (on && isVisible()) {
11305  // Make sure we keep the current state and only hide the widget
11306  // from the desktop. show_sys will only update platform specific
11307  // attributes at this point.
11308  d->hide_sys();
11309 #ifdef Q_WS_QWS
11310  // Release the region for this window from qws if the widget has
11311  // been shown before the attribute was set.
11312  if (QWSWindowSurface *surface = static_cast<QWSWindowSurface *>(windowSurface())) {
11313  QWidget::qwsDisplay()->requestRegion(surface->winId(), surface->key(),
11314  surface->permanentState(), QRegion());
11315  }
11316 #endif
11317  d->show_sys();
11318  }
11319  break;
11320  }
11321 
11322 #ifdef Q_WS_X11
11337  d->setNetWmWindowTypes();
11338  break;
11339 #endif
11340 
11341  case Qt::WA_StaticContents:
11342  if (QWidgetBackingStore *bs = d->maybeBackingStore()) {
11343  if (on)
11344  bs->addStaticWidget(this);
11345  else
11346  bs->removeStaticWidget(this);
11347  }
11348  break;
11350 #if defined(Q_OS_SYMBIAN)
11352 #else
11353  if (on) {
11355  d->updateIsTranslucent();
11356  }
11357 #endif
11358  break;
11360 #if defined(Q_WS_WIN) || defined(Q_WS_MAC) || defined(Q_OS_SYMBIAN)
11361  if (on)
11362  d->registerTouchWindow();
11363 #endif
11364  break;
11367  case Qt::WA_AutoOrientation: {
11368  const Qt::WidgetAttribute orientations[3] = {
11372  };
11373 
11374  if (on) {
11375  // We can only have one of these set at a time
11376  for (int i = 0; i < 3; ++i) {
11377  if (orientations[i] != attribute)
11378  setAttribute_internal(orientations[i], false, data, d);
11379  }
11380  }
11381 
11382 #ifdef Q_OS_BLACKBERRY
11383  if (testAttribute(Qt::WA_AutoOrientation)) {
11384  navigator_rotation_lock(false);
11385  } else {
11386 #ifdef Q_OS_BLACKBERRY_TABLET
11387  const bool portraitLocked = testAttribute(Qt::WA_LockPortraitOrientation);
11388 
11389  orientation_direction_t direction;
11390  orientation_get(&direction, 0);
11391 
11392  int rotation = 0;
11393 
11394  switch (direction) {
11395  case ORIENTATION_TOP_UP:
11396  case ORIENTATION_RIGHT_UP:
11397  rotation = portraitLocked ? 90 : 0;
11398  break;
11399  case ORIENTATION_BOTTOM_UP:
11400  case ORIENTATION_LEFT_UP:
11401  rotation = portraitLocked ? 270 : 180;
11402  break;
11403  default:
11404  break;
11405  }
11406 
11407  navigator_set_orientation(rotation, 0);
11408 #else
11409  navigator_set_orientation_mode((testAttribute(Qt::WA_LockPortraitOrientation) ?
11410  NAVIGATOR_PORTRAIT : NAVIGATOR_LANDSCAPE), 0);
11411 #endif // Q_OS_BLACKBERRY_TABLET
11412  navigator_rotation_lock(true);
11413  }
11414 #endif // Q_OS_BLACKBERRY
11415 
11416 #ifdef Q_WS_S60
11417  CAknAppUiBase* appUi = static_cast<CAknAppUiBase*>(CEikonEnv::Static()->EikAppUi());
11418  const CAknAppUiBase::TAppUiOrientation s60orientations[] = {
11419  CAknAppUiBase::EAppUiOrientationPortrait,
11420  CAknAppUiBase::EAppUiOrientationLandscape,
11421  CAknAppUiBase::EAppUiOrientationAutomatic
11422  };
11423  CAknAppUiBase::TAppUiOrientation s60orientation = CAknAppUiBase::EAppUiOrientationUnspecified;
11424  for (int i = 0; i < 3; ++i) {
11425  if (testAttribute(orientations[i])) {
11426  s60orientation = s60orientations[i];
11427  break;
11428  }
11429  }
11430  QT_TRAP_THROWING(appUi->SetOrientationL(s60orientation));
11431  S60->orientationSet = true;
11432  QSymbianControl *window = static_cast<QSymbianControl *>(internalWinId());
11433  if (window)
11434  window->ensureFixNativeOrientation();
11435 #endif
11436  break;
11437  }
11438  default:
11439  break;
11440  }
11441 }
double d
Definition: qnumeric_p.h:62
The QWSWindowSurface class provides the drawing area for top-level windows in Qt for Embedded Linux...
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
QWidget * focusWidget() const
Returns the last child of this widget that setFocus had been called on.
Definition: qwidget.cpp:6863
static QWSDisplay * qwsDisplay()
bool isWindow() const
Returns true if the widget is an independent window, otherwise returns false.
Definition: qwidget.h:945
bool isVisible() const
Definition: qwidget.h:1005
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
void qt_mac_update_mouseTracking(QWidget *widget)
QWidget * focusWidget() const
Returns the widget that has an input focus for this input context.
bool hasFocus() const
Definition: qwidget.cpp:6583
T * qobject_cast(QObject *object)
Definition: qobject.h:375
#define Q_D(Class)
Definition: qglobal.h:2482
WidgetAttribute
Definition: qnamespace.h:376
QStyle * style() const
Definition: qwidget.cpp:2742
uint window_modality
Definition: qwidget.h:128
void clearFocus()
Takes keyboard input focus from the widget.
Definition: qwidget.cpp:6757
void requestRegion(int winId, const QString &surfacekey, const QByteArray &surfaceData, const QRegion &region)
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
#define qApp
QWidgetData * data
Definition: qwidget.h:815
unsigned int uint
Definition: qglobal.h:996
QWindowSurface * windowSurface() const
Returns the QWindowSurface this widget will be drawn into.
Definition: qwidget.cpp:12819
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
bool inherits(const char *classname) const
Returns true if this object is an instance of a class that inherits className or a QObject subclass t...
Definition: qobject.h:275
QInputContext * inputContext()
This function returns the QInputContext for this widget.
Definition: qwidget.cpp:474
bool isEnabled() const
Definition: qwidget.h:948
void setFocus()
Gives the keyboard input focus to this widget (or its focus proxy) if this widget or one of its paren...
Definition: qwidget.h:432
#define Q_ASSERT_X(cond, where, what)
Definition: qglobal.h:1837
QPaintEngine * paintEngine() const
Returns the widget&#39;s paint engine.
virtual void reset()=0
This function can be reimplemented in a subclass to reset the state of the input method.
WId internalWinId() const
Returns the window system identifier of the widget, or 0 if the widget is not created yet...
Definition: qwidget.h:244
static void setAttribute_internal(Qt::WidgetAttribute attribute, bool on, QWidgetData *data, QWidgetPrivate *d)
Definition: qwidget.cpp:11063
void setAttribute(Qt::WidgetAttribute, bool on=true)
Sets the attribute attribute on this widget if on is true; otherwise clears the attribute.
Definition: qwidget.cpp:11087
QWidget * window() const
Returns the window for this widget, i.e.
Definition: qwidget.cpp:4492
The QInputContext class abstracts the input method dependent data and composing state.
Definition: qinputcontext.h:83
virtual void setFocusWidget(QWidget *w)
Sets the widget that has an input focus for this input context.
The QEvent class is the base class of all event classes.
Definition: qcoreevent.h:56
static void leaveModal(QWidget *)
Qt::LayoutDirection direction

◆ setAutoFillBackground()

void QWidget::setAutoFillBackground ( bool  enabled)

Definition at line 631 of file qwidget.cpp.

Referenced by QWorkspace::addWindow(), QCalendarWidgetPrivate::createNavigationBar(), QMainWindowLayout::getSeparatorWidget(), QStyleSheetStyle::polish(), QCalendarWidget::QCalendarWidget(), QMdiSubWindow::QMdiSubWindow(), QWorkspaceChild::QWorkspaceChild(), QWizardPrivate::recreateLayout(), QGraphicsView::setupViewport(), and QStyleSheetStyle::unsetPalette().

632 {
633  Q_D(QWidget);
634  if (!d->extra)
635  d->createExtra();
636  if (d->extra->autoFillBackground == enabled)
637  return;
638 
639  d->extra->autoFillBackground = enabled;
640  d->updateIsOpaque();
641  update();
642  d->updateIsOpaque();
643 }
double d
Definition: qnumeric_p.h:62
bool enabled
whether the widget is enabled
Definition: qwidget.h:157
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_D(Class)
Definition: qglobal.h:2482
void update()
Updates the widget unless updates are disabled or the widget is hidden.
Definition: qwidget.cpp:10883

◆ setBackgroundRole()

void QWidget::setBackgroundRole ( QPalette::ColorRole  role)

Sets the background role of the widget to role.

The background role defines the brush from the widget's palette that is used to render the background.

If role is QPalette::NoRole, then the widget inherits its parent's background role.

Note that styles are free to choose any color from the palette. You can modify the palette or set a style sheet if you don't achieve the result you want with setBackgroundRole().

See also
backgroundRole(), foregroundRole()

Definition at line 4708 of file qwidget.cpp.

Referenced by QCalendarWidgetPrivate::createNavigationBar(), QTextEditPrivate::init(), QAbstractItemViewPrivate::init(), QPlainTextEditPrivate::init(), nativeParentWidget(), QToolBoxButton::paintEvent(), QPlastiqueStyle::polish(), QCalendarWidget::QCalendarWidget(), QGraphicsView::QGraphicsView(), QMdiSubWindow::QMdiSubWindow(), QTipLabel::QTipLabel(), QToolBox::QToolBox(), QToolBoxButton::QToolBoxButton(), QWizardHeader::QWizardHeader(), QWorkspaceChild::QWorkspaceChild(), QWizardPrivate::recreateLayout(), QPlastiqueStyle::unpolish(), and QToolBoxPrivate::updateTabs().

4709 {
4710  Q_D(QWidget);
4711  d->bg_role = role;
4712  d->updateSystemBackground();
4713  d->propagatePaletteChange();
4714  d->updateIsOpaque();
4715 }
double d
Definition: qnumeric_p.h:62
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_D(Class)
Definition: qglobal.h:2482

◆ setBaseSize() [1/2]

void QWidget::setBaseSize ( const QSize s)
inline

Definition at line 978 of file qwidget.h.

Referenced by QWorkspaceChild::QWorkspaceChild().

979 { setBaseSize(s.width(),s.height()); }
void setBaseSize(const QSize &)
Definition: qwidget.h:978
int width() const
Returns the width.
Definition: qsize.h:126
int height() const
Returns the height.
Definition: qsize.h:129

◆ setBaseSize() [2/2]

void QWidget::setBaseSize ( int  basew,
int  baseh 
)

This corresponds to setBaseSize(QSize(basew, baseh)).

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Sets the widgets base size to width basew and height baseh.

Definition at line 4256 of file qwidget.cpp.

4257 {
4258  Q_D(QWidget);
4259  d->createTLExtra();
4260  QTLWExtra* x = d->topData();
4261  if (x->basew == basew && x->baseh == baseh)
4262  return;
4263  x->basew = basew;
4264  x->baseh = baseh;
4265  if (isWindow())
4266  d->setConstraints_sys();
4267 }
double d
Definition: qnumeric_p.h:62
bool isWindow() const
Returns true if the widget is an independent window, otherwise returns false.
Definition: qwidget.h:945
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
short baseh
Definition: qwidget_p.h:178
#define Q_D(Class)
Definition: qglobal.h:2482
int x() const
short basew
Definition: qwidget_p.h:178

◆ setContentsMargins() [1/2]

void QWidget::setContentsMargins ( int  left,
int  top,
int  right,
int  bottom 
)

Sets the margins around the contents of the widget to have the sizes left, top, right, and bottom.

The margins are used by the layout system, and may be used by subclasses to specify the area to draw in (e.g. excluding the frame).

Changing the margins will trigger a resizeEvent().

See also
contentsRect(), getContentsMargins()

Definition at line 7449 of file qwidget.cpp.

Referenced by QBalloonTip::balloon(), QMdiSubWindow::event(), QWindowsVistaStyle::polish(), QWorkspaceChild::QWorkspaceChild(), QWizardPrivate::recreateLayout(), QSplitterHandle::resizeEvent(), setContentsMargins(), QFrame::setFrameRect(), QMessageBox::setInformativeText(), and QWindowsVistaStyle::unpolish().

7450 {
7451  Q_D(QWidget);
7452  if (left == d->leftmargin && top == d->topmargin
7453  && right == d->rightmargin && bottom == d->bottommargin)
7454  return;
7455  d->leftmargin = left;
7456  d->topmargin = top;
7457  d->rightmargin = right;
7458  d->bottommargin = bottom;
7459 
7460  if (QLayout *l=d->layout)
7461  l->update(); //force activate; will do updateGeometry
7462  else
7463  updateGeometry();
7464 
7465  // ### Qt 5: compat, remove
7466  if (isVisible()) {
7467  update();
7469  QApplication::sendEvent(this, &e);
7470  } else {
7472  }
7473 
7475  QApplication::sendEvent(this, &e);
7476 }
double d
Definition: qnumeric_p.h:62
QRect crect
Definition: qwidget.h:131
bool isVisible() const
Definition: qwidget.h:1005
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_D(Class)
Definition: qglobal.h:2482
Q_CORE_EXPORT QTextStream & right(QTextStream &s)
void update()
Updates the widget unless updates are disabled or the widget is hidden.
Definition: qwidget.cpp:10883
The QLayout class is the base class of geometry managers.
Definition: qlayout.h:90
QSize size() const
Returns the size of the rectangle.
Definition: qrect.h:309
QWidgetData * data
Definition: qwidget.h:815
The QResizeEvent class contains event parameters for resize events.
Definition: qevent.h:349
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
QFactoryLoader * l
void setAttribute(Qt::WidgetAttribute, bool on=true)
Sets the attribute attribute on this widget if on is true; otherwise clears the attribute.
Definition: qwidget.cpp:11087
void updateGeometry()
Notifies the layout system that this widget has changed and may need to change geometry.
Definition: qwidget.cpp:10372
The QEvent class is the base class of all event classes.
Definition: qcoreevent.h:56
Q_CORE_EXPORT QTextStream & left(QTextStream &s)

◆ setContentsMargins() [2/2]

void QWidget::setContentsMargins ( const QMargins margins)

The setContentsMargins function sets the margins around the widget's contents.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Since
4.6

Sets the margins around the contents of the widget to have the sizes determined by margins. The margins are used by the layout system, and may be used by subclasses to specify the area to draw in (e.g. excluding the frame).

Changing the margins will trigger a resizeEvent().

See also
contentsRect(), getContentsMargins()

Definition at line 7497 of file qwidget.cpp.

7498 {
7499  setContentsMargins(margins.left(), margins.top(),
7500  margins.right(), margins.bottom());
7501 }
int top() const
Returns the top margin.
Definition: qmargins.h:99
void setContentsMargins(int left, int top, int right, int bottom)
Sets the margins around the contents of the widget to have the sizes left, top, right, and bottom.
Definition: qwidget.cpp:7449
int left() const
Returns the left margin.
Definition: qmargins.h:96
int bottom() const
Returns the bottom margin.
Definition: qmargins.h:105
int right() const
Returns the right margin.
Definition: qmargins.h:102

◆ setContextMenuPolicy()

void QWidget::setContextMenuPolicy ( Qt::ContextMenuPolicy  policy)

Definition at line 7596 of file qwidget.cpp.

Referenced by QFileDialogPrivate::createWidgets(), QSidebar::init(), QFileDialogListView::init(), and QFileDialogTreeView::init().

7597 {
7598  data->context_menu_policy = (uint) policy;
7599 }
QWidgetData * data
Definition: qwidget.h:815
unsigned int uint
Definition: qglobal.h:996
uint context_menu_policy
Definition: qwidget.h:127

◆ setCursor()

void QWidget::setCursor ( const QCursor cursor)

Definition at line 5290 of file qwidget.cpp.

Referenced by QTextBrowserPrivate::_q_activateAnchor(), QTextBrowserPrivate::_q_highlightLink(), QGraphicsViewPrivate::_q_setViewportCursor(), QGraphicsViewPrivate::_q_unsetViewportCursor(), QmlJSDebugger::ColorPickerTool::clear(), QmlJSDebugger::ZoomTool::clear(), QmlJSDebugger::LiveSelectionTool::clear(), CloseButton::CloseButton(), QToolBar::event(), QScriptEdit::extraAreaMouseEvent(), QTextBrowserPrivate::init(), QTextEditPrivate::init(), QPlainTextEditPrivate::init(), QWorkspaceChild::leaveEvent(), QHeaderView::mouseDoubleClickEvent(), QWhatsThat::mouseMoveEvent(), QHeaderView::mouseMoveEvent(), QGraphicsViewPrivate::mouseMoveEventHandler(), QGraphicsView::mousePressEvent(), QGraphicsView::mouseReleaseEvent(), QSizeGrip::moveEvent(), QColumnViewGrip::QColumnViewGrip(), QWhatsThat::QWhatsThat(), QProgressDialog::reset(), QGraphicsView::setDragMode(), QVistaHelper::setMouseCursor(), QWidgetResizeHandler::setMouseCursor(), QSplitterHandle::setOrientation(), and QLineEdit::setReadOnly().

5291 {
5292  Q_D(QWidget);
5293 // On Mac we must set the cursor even if it is the ArrowCursor.
5294 #if !defined(Q_WS_MAC) && !defined(Q_WS_QWS)
5295  if (cursor.shape() != Qt::ArrowCursor
5296  || (d->extra && d->extra->curs))
5297 #endif
5298  {
5299  d->createExtra();
5300  QCursor *newCursor = new QCursor(cursor);
5301  delete d->extra->curs;
5302  d->extra->curs = newCursor;
5303  }
5305  d->setCursor_sys(cursor);
5306 
5309 }
double d
Definition: qnumeric_p.h:62
The QCursor class provides a mouse cursor with an arbitrary shape.
Definition: qcursor.h:89
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_D(Class)
Definition: qglobal.h:2482
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
void setAttribute(Qt::WidgetAttribute, bool on=true)
Sets the attribute attribute on this widget if on is true; otherwise clears the attribute.
Definition: qwidget.cpp:11087
bool event(QEvent *)
This is the main event handler; it handles event event.
Definition: qwidget.cpp:8636
The QEvent class is the base class of all event classes.
Definition: qcoreevent.h:56
Qt::CursorShape shape() const
Returns the cursor shape identifier.
Definition: qcursor.cpp:469

◆ setDisabled

void QWidget::setDisabled ( bool  disable)
slot

Disables widget input events if disable is true; otherwise enables input events.

See the enabled documentation for more information.

See also
isEnabledTo(), QKeyEvent, QMouseEvent, changeEvent()

Definition at line 3589 of file qwidget.cpp.

3590 {
3591  setEnabled(!disable);
3592 }
void setEnabled(bool)
Definition: qwidget.cpp:3447

◆ setEnabled

void QWidget::setEnabled ( bool  enable)
slot

Definition at line 3447 of file qwidget.cpp.

Referenced by QInputDialogPrivate::_q_currentRowChanged(), QPrintDialogPrivate::_q_printerOrFileSelected(), QPrintDialogPrivate::_q_printRangeSelected(), QGroupBoxPrivate::_q_setChildrenEnabled(), QScriptDebuggerCodeFinderWidgetPrivate::_q_updateButtons(), QFileDialogPrivate::_q_updateOkButton(), QX11EmbedContainerPrivate::acceptClient(), QGroupBox::childEvent(), QX11EmbedContainer::eventFilter(), QScriptDebuggerPrivate::handleResponse(), QToolBarLayout::layoutActions(), QTabBarPrivate::layoutTabs(), QTabBarPrivate::makeVisible(), QScriptNewBreakpointWidget::onTextChanged(), QAlphaWidget::QAlphaWidget(), QRollEffect::QRollEffect(), QScriptNewBreakpointWidget::QScriptNewBreakpointWidget(), QTornOffMenu::QTornOffMenu(), QX11EmbedContainer::QX11EmbedContainer(), QAlphaWidget::render(), QAlphaWidget::run(), QRollEffect::run(), QRollEffect::scroll(), QToolButton::setDefaultAction(), setDisabled(), QInputDialogPrivate::setInputWidget(), QToolBox::setItemEnabled(), QPrintDialogPrivate::setPrinter(), QTabWidget::setTabEnabled(), QCalendarWidgetPrivate::updateMonthMenu(), and QX11EmbedContainer::x11Event().

3448 {
3449  Q_D(QWidget);
3451  d->setEnabled_helper(enable);
3452 }
double d
Definition: qnumeric_p.h:62
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_D(Class)
Definition: qglobal.h:2482
void setAttribute(Qt::WidgetAttribute, bool on=true)
Sets the attribute attribute on this widget if on is true; otherwise clears the attribute.
Definition: qwidget.cpp:11087

◆ setFixedHeight()

void QWidget::setFixedHeight ( int  h)

Sets both the minimum and maximum heights of the widget to h without changing the widths.

Provided for convenience.

See also
sizeHint() minimumSize() maximumSize() setFixedSize()

Definition at line 4388 of file qwidget.cpp.

Referenced by QMessageBoxDetailsText::QMessageBoxDetailsText(), and QAxClientSite::qt_metacall().

4389 {
4390  Q_D(QWidget);
4391  d->createExtra();
4392  uint explMin = d->extra->explicitMinSize | Qt::Vertical;
4393  uint explMax = d->extra->explicitMaxSize | Qt::Vertical;
4396  d->extra->explicitMinSize = explMin;
4397  d->extra->explicitMaxSize = explMax;
4398 }
double d
Definition: qnumeric_p.h:62
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
void setMaximumSize(const QSize &)
Definition: qwidget.h:972
void setMinimumSize(const QSize &)
Definition: qwidget.h:969
#define Q_D(Class)
Definition: qglobal.h:2482
int width() const
unsigned int uint
Definition: qglobal.h:996
QSize maximumSize() const
QSize minimumSize() const

◆ setFixedSize() [1/2]

void QWidget::setFixedSize ( const QSize s)

Sets both the minimum and maximum sizes of the widget to s, thereby preventing it from ever growing or shrinking.

This will override the default size constraints set by QLayout.

To remove constraints, set the size to QWIDGETSIZE_MAX.

Alternatively, if you want the widget to have a fixed size based on its contents, you can call QLayout::setSizeConstraint(QLayout::SetFixedSize);

See also
maximumSize, minimumSize

Definition at line 4284 of file qwidget.cpp.

Referenced by QTornOffMenu::actionEvent(), QLayout::activate(), QLayout::addChildWidget(), QMdi::ControlLabel::ControlLabel(), QDialogButtonBox::event(), QMessageBoxPrivate::hideSpecial(), QBalloonTip::QBalloonTip(), QMdiSubWindowPrivate::setSizeGrip(), QWizardHeader::setup(), and QDialog::showExtension().

4285 {
4286  setFixedSize(s.width(), s.height());
4287 }
int width() const
Returns the width.
Definition: qsize.h:126
void setFixedSize(const QSize &)
Sets both the minimum and maximum sizes of the widget to s, thereby preventing it from ever growing o...
Definition: qwidget.cpp:4284
int height() const
Returns the height.
Definition: qsize.h:129

◆ setFixedSize() [2/2]

void QWidget::setFixedSize ( int  w,
int  h 
)

Sets the width of the widget to w and the height to h.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 4300 of file qwidget.cpp.

4301 {
4302  Q_D(QWidget);
4303 #ifdef Q_WS_QWS
4304  // temporary fix for 4.3.x.
4305  // Should move the embedded spesific contraints in setMinimumSize_helper into QLayout
4306  int tmpW = w;
4307  int tmpH = h;
4308  bool minSizeSet = d->setMinimumSize_helper(tmpW, tmpH);
4309 #else
4310  bool minSizeSet = d->setMinimumSize_helper(w, h);
4311 #endif
4312  bool maxSizeSet = d->setMaximumSize_helper(w, h);
4313  if (!minSizeSet && !maxSizeSet)
4314  return;
4315 
4316  if (isWindow())
4317  d->setConstraints_sys();
4318  else
4319  d->updateGeometry_helper(true);
4320 
4321  if (w != QWIDGETSIZE_MAX || h != QWIDGETSIZE_MAX)
4322  resize(w, h);
4323 }
double d
Definition: qnumeric_p.h:62
bool isWindow() const
Returns true if the widget is an independent window, otherwise returns false.
Definition: qwidget.h:945
#define QWIDGETSIZE_MAX
Defines the maximum size for a QWidget object.
Definition: qwidget.h:1087
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_D(Class)
Definition: qglobal.h:2482
void resize(int w, int h)
This corresponds to resize(QSize(w, h)).
Definition: qwidget.h:1014

◆ setFixedWidth()

void QWidget::setFixedWidth ( int  w)

Sets both the minimum and maximum width of the widget to w without changing the heights.

Provided for convenience.

See also
sizeHint() minimumSize() maximumSize() setFixedSize()

Definition at line 4368 of file qwidget.cpp.

Referenced by QFontComboBox::event(), and QAxClientSite::qt_metacall().

4369 {
4370  Q_D(QWidget);
4371  d->createExtra();
4372  uint explMin = d->extra->explicitMinSize | Qt::Horizontal;
4373  uint explMax = d->extra->explicitMaxSize | Qt::Horizontal;
4376  d->extra->explicitMinSize = explMin;
4377  d->extra->explicitMaxSize = explMax;
4378 }
double d
Definition: qnumeric_p.h:62
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
void setMaximumSize(const QSize &)
Definition: qwidget.h:972
void setMinimumSize(const QSize &)
Definition: qwidget.h:969
#define Q_D(Class)
Definition: qglobal.h:2482
int height() const
unsigned int uint
Definition: qglobal.h:996
QSize maximumSize() const
QSize minimumSize() const

◆ setFocus [1/2]

void QWidget::setFocus ( )
inlineslot

Gives the keyboard input focus to this widget (or its focus proxy) if this widget or one of its parents is the active window.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 432 of file qwidget.h.

Referenced by QColumnViewPrivate::_q_changeCurrentColumn(), QScriptDebuggerPrivate::_q_findInScript(), QGroupBoxPrivate::_q_fixFocus(), QPrintDialogPrivate::_q_printerOrFileSelected(), QCalendarWidgetPrivate::_q_yearClicked(), QAxServerBase::ActiveXProc(), QGraphicsScenePrivate::addPopup(), QMdiArea::addSubWindow(), QAbstractButton::animateClick(), QAbstractItemView::closeEditor(), QApplicationPrivate::closePopup(), QAccessibleWidget::doAction(), QColorWell::dragLeaveEvent(), QGroupBox::event(), QAbstractButton::event(), QLabel::event(), QStyledItemDelegate::eventFilter(), QItemDelegate::eventFilter(), QCalendarWidget::eventFilter(), QMenu::focusNextPrevChild(), focusNextPrevChild(), QWidgetPrivate::frameStrut(), QApplicationPrivate::giveFocusAccordingToFocusPolicy(), QMenu::keyPressEvent(), QFileDialogLineEdit::keyPressEvent(), QAbstractItemView::keyPressEvent(), QMdiSubWindowPrivate::leaveInteractiveMode(), make_widget_eventUPP(), QCalendarWidget::mousePressEvent(), QAbstractButtonPrivate::moveFocus(), QAbstractItemViewPrivate::openEditor(), QApplicationPrivate::openPopup(), qt_try_modal(), QApplication::qwsProcessEvent(), QAlphaWidget::render(), resetInputContext(), QMdiSubWindowPrivate::restoreFocus(), QRollEffect::scroll(), QWorkspaceChild::setActive(), QApplication::setActiveWindow(), setAttribute(), QCalendarPopup::setCalendarWidget(), QMenuBarPrivate::setCurrentAction(), QMenuPrivate::setCurrentAction(), QStackedLayout::setCurrentIndex(), QMessageBox::setDefaultButton(), setFocus(), QMdiSubWindowPrivate::setFocusWidget(), QWidgetPrivate::show_helper(), QComboBox::showPopup(), QWizardPrivate::switchToPage(), and QX11EmbedContainer::x11Event().

void setFocus()
Gives the keyboard input focus to this widget (or its focus proxy) if this widget or one of its paren...
Definition: qwidget.h:432

◆ setFocus() [2/2]

void QWidget::setFocus ( Qt::FocusReason  reason)

Gives the keyboard input focus to this widget (or its focus proxy) if this widget or one of its parents is the active window.

The reason argument will be passed into any focus event sent from this function, it is used to give an explanation of what caused the widget to get focus. If the window is not active, the widget will be given the focus when the window becomes active.

First, a focus out event is sent to the focus widget (if any) to tell it that it is about to lose the focus. Then a focus in event is sent to this widget to tell it that it just received the focus. (Nothing happens if the focus in and focus out widgets are the same.)

Note
On embedded platforms, setFocus() will not cause an input panel to be opened by the input method. If you want this to happen, you have to send a QEvent::RequestSoftwareInputPanel event to the widget yourself.

setFocus() gives focus to a widget regardless of its focus policy, but does not clear any keyboard grab (see grabKeyboard()).

Be aware that if the widget is hidden, it will not accept focus until it is shown.

Warning
If you call setFocus() in a function which may itself be called from focusOutEvent() or focusInEvent(), you may get an infinite recursion.
See also
hasFocus(), clearFocus(), focusInEvent(), focusOutEvent(), setFocusPolicy(), focusWidget(), QApplication::focusWidget(), grabKeyboard(), grabMouse(), {Keyboard Focus}, QEvent::RequestSoftwareInputPanel

Definition at line 6633 of file qwidget.cpp.

6634 {
6635  if (!isEnabled())
6636  return;
6637 
6638  QWidget *f = this;
6639  while (f->d_func()->extra && f->d_func()->extra->focus_proxy)
6640  f = f->d_func()->extra->focus_proxy;
6641 
6642  if (QApplication::focusWidget() == f
6643 #if defined(Q_WS_WIN)
6644  && GetFocus() == f->internalWinId()
6645 #endif
6646  )
6647  return;
6648 
6649 #ifndef QT_NO_GRAPHICSVIEW
6650  QWidget *previousProxyFocus = 0;
6651  if (QWExtra *topData = window()->d_func()->extra) {
6652  if (topData->proxyWidget && topData->proxyWidget->hasFocus()) {
6653  previousProxyFocus = topData->proxyWidget->widget()->focusWidget();
6654  if (previousProxyFocus && previousProxyFocus->focusProxy())
6655  previousProxyFocus = previousProxyFocus->focusProxy();
6656  if (previousProxyFocus == this && !topData->proxyWidget->d_func()->proxyIsGivingFocus)
6657  return;
6658  }
6659  }
6660 #endif
6661 
6662  QWidget *w = f;
6663  if (isHidden()) {
6664  while (w && w->isHidden()) {
6665  w->d_func()->focus_child = f;
6666  w = w->isWindow() ? 0 : w->parentWidget();
6667  }
6668  } else {
6669  while (w) {
6670  w->d_func()->focus_child = f;
6671  w = w->isWindow() ? 0 : w->parentWidget();
6672  }
6673  }
6674 
6675 #ifndef QT_NO_GRAPHICSVIEW
6676  // Update proxy state
6677  if (QWExtra *topData = window()->d_func()->extra) {
6678  if (topData->proxyWidget && !topData->proxyWidget->hasFocus()) {
6679  topData->proxyWidget->d_func()->focusFromWidgetToProxy = 1;
6680  topData->proxyWidget->setFocus(reason);
6681  topData->proxyWidget->d_func()->focusFromWidgetToProxy = 0;
6682  }
6683  }
6684 #endif
6685 
6686  if (f->isActiveWindow()) {
6688 #ifndef QT_NO_ACCESSIBILITY
6689 # ifdef Q_OS_WIN
6690  // The negation of the condition in setFocus_sys
6692  //setFocusWidget will already post a focus event for us (that the AT client receives) on Windows
6693 # endif
6694 # ifdef Q_OS_UNIX
6695  // menus update the focus manually and this would create bogus events
6696  if (!(f->inherits("QMenuBar") || f->inherits("QMenu") || f->inherits("QMenuItem")))
6697 # endif
6699 #endif
6700 #ifndef QT_NO_GRAPHICSVIEW
6701  if (QWExtra *topData = window()->d_func()->extra) {
6702  if (topData->proxyWidget) {
6703  if (previousProxyFocus && previousProxyFocus != f) {
6704  // Send event to self
6706  QPointer<QWidget> that = previousProxyFocus;
6707  QApplication::sendEvent(previousProxyFocus, &event);
6708  if (that)
6709  QApplication::sendEvent(that->style(), &event);
6710  }
6711  if (!isHidden()) {
6712 #ifndef QT_NO_GRAPHICSVIEW
6713  // Update proxy state
6714  if (QWExtra *topData = window()->d_func()->extra)
6715  if (topData->proxyWidget && topData->proxyWidget->hasFocus())
6716  topData->proxyWidget->d_func()->updateProxyInputMethodAcceptanceFromWidget();
6717 #endif
6718  // Send event to self
6720  QPointer<QWidget> that = f;
6722  if (that)
6723  QApplication::sendEvent(that->style(), &event);
6724  }
6725  }
6726  }
6727 #endif
6728  }
6729 }
static void updateAccessibility(QObject *, int who, Event reason)
Notifies accessibility clients about a change in object&#39;s accessibility information.
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
QWidget * focusWidget() const
Returns the last child of this widget that setFocus had been called on.
Definition: qwidget.cpp:6863
bool isActiveWindow
whether this widget&#39;s window is the active window
Definition: qwidget.h:186
bool isWindow() const
Returns true if the widget is an independent window, otherwise returns false.
Definition: qwidget.h:945
#define Q_WS_WIN
Defined on Windows.
Definition: qglobal.h:921
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
QWidget * focusProxy() const
Returns the focus proxy, or 0 if there is no focus proxy.
Definition: qwidget.cpp:6561
QStyle * style() const
Definition: qwidget.cpp:2742
bool isHidden() const
Returns true if the widget is hidden, otherwise returns false.
Definition: qwidget.h:1008
static void setFocusWidget(QWidget *focus, Qt::FocusReason reason)
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
bool inherits(const char *classname) const
Returns true if this object is an instance of a class that inherits className or a QObject subclass t...
Definition: qobject.h:275
bool isEnabled() const
Definition: qwidget.h:948
void setFocus()
Gives the keyboard input focus to this widget (or its focus proxy) if this widget or one of its paren...
Definition: qwidget.h:432
WId internalWinId() const
Returns the window system identifier of the widget, or 0 if the widget is not created yet...
Definition: qwidget.h:244
QWidget * window() const
Returns the window for this widget, i.e.
Definition: qwidget.cpp:4492
Qt::WindowType windowType() const
Returns the window type of this widget.
Definition: qwidget.h:937
bool event(QEvent *)
This is the main event handler; it handles event event.
Definition: qwidget.cpp:8636
static QWidget * focusWidget()
Returns the application widget that has the keyboard input focus, or 0 if no widget in this applicati...
The QFocusEvent class contains event parameters for widget focus events.
Definition: qevent.h:275

◆ setFocusPolicy()

void QWidget::setFocusPolicy ( Qt::FocusPolicy  policy)

Definition at line 7631 of file qwidget.cpp.

Referenced by QColumnViewPrivate::_q_changeCurrentColumn(), QAxClientSite::activateObject(), QAxWidget::clear(), CloseButton::CloseButton(), QMdi::ControlLabel::ControlLabel(), QMdi::ControllerWidget::ControllerWidget(), QColumnViewPrivate::createColumn(), QToolBarLayout::createItem(), QCalendarWidgetPrivate::createNavigationBar(), QAbstractButtonPrivate::fixFocusPolicy(), QTabBarPrivate::init(), QHeaderView::initialize(), QCalendarWidget::QCalendarWidget(), QDockWidgetTitleButton::QDockWidgetTitleButton(), QFocusFrame::QFocusFrame(), QMdiArea::QMdiArea(), QMDIControl::QMDIControl(), QMdiSubWindow::QMdiSubWindow(), QMessageBoxDetailsText::QMessageBoxDetailsText(), QToolBarLayout::QToolBarLayout(), QToolBoxButton::QToolBoxButton(), QVistaBackButton::QVistaBackButton(), QWellArray::QWellArray(), QWhatsThat::QWhatsThat(), QX11EmbedContainer::QX11EmbedContainer(), QX11EmbedWidget::QX11EmbedWidget(), QGroupBox::setCheckable(), QCompleter::setPopup(), QLabel::setTextInteractionFlags(), and QGraphicsView::setupViewport().

7632 {
7633  data->focus_policy = (uint) policy;
7634  Q_D(QWidget);
7635  if (d->extra && d->extra->focus_proxy)
7636  d->extra->focus_proxy->setFocusPolicy(policy);
7637 }
double d
Definition: qnumeric_p.h:62
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_D(Class)
Definition: qglobal.h:2482
QWidgetData * data
Definition: qwidget.h:815
unsigned int uint
Definition: qglobal.h:996
uint focus_policy
Definition: qwidget.h:121

◆ setFocusProxy()

void QWidget::setFocusProxy ( QWidget w)

Sets the widget's focus proxy to widget w.

If w is 0, the function resets this widget to have no focus proxy.

Some widgets can "have focus", but create a child widget, such as QLineEdit, to actually handle the focus. In this case, the widget can set the line edit to be its focus proxy.

setFocusProxy() sets the widget which will actually get focus when "this widget" gets it. If there is a focus proxy, setFocus() and hasFocus() operate on the focus proxy.

See also
focusProxy()

Definition at line 6537 of file qwidget.cpp.

Referenced by QAxClientSite::activateObject(), QDialogButtonBoxPrivate::layoutButtons(), QCalendarWidget::QCalendarWidget(), QScriptDebuggerCodeFinderWidget::QScriptDebuggerCodeFinderWidget(), QScriptNewBreakpointWidget::QScriptNewBreakpointWidget(), QCompleter::setPopup(), and QTabWidget::setTabBar().

6538 {
6539  Q_D(QWidget);
6540  if (!w && !d->extra)
6541  return;
6542 
6543  for (QWidget* fp = w; fp; fp = fp->focusProxy()) {
6544  if (fp == this) {
6545  qWarning("QWidget: %s (%s) already in focus proxy chain", metaObject()->className(), objectName().toLocal8Bit().constData());
6546  return;
6547  }
6548  }
6549 
6550  d->createExtra();
6551  d->extra->focus_proxy = w;
6552 }
double d
Definition: qnumeric_p.h:62
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_D(Class)
Definition: qglobal.h:2482
QWidget * focusProxy() const
Returns the focus proxy, or 0 if there is no focus proxy.
Definition: qwidget.cpp:6561
const char * className
Definition: qwizard.cpp:137
Q_CORE_EXPORT void qWarning(const char *,...)
QString objectName() const
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.

◆ setFont()

void QWidget::setFont ( const QFont font)

Use the single-argument overload instead.

Definition at line 4996 of file qwidget.cpp.

Referenced by QCalendarWidgetPrivate::createNavigationBar(), QListWidgetItem::font(), QMacStyle::polish(), QWindowsVistaStyle::polish(), QBalloonTip::QBalloonTip(), QWizardHeader::QWizardHeader(), QWizardPrivate::recreateLayout(), QToolButton::setDefaultAction(), QMessageBox::setInformativeText(), QWindowsVistaStyle::unpolish(), QStyleSheetStyle::unsetPalette(), and QTextEdit::zoomIn().

4997 {
4998  Q_D(QWidget);
4999 
5000 #ifndef QT_NO_STYLE_STYLESHEET
5001  const QStyleSheetStyle* style;
5002  if (d->extra && (style = qobject_cast<const QStyleSheetStyle*>(d->extra->style))) {
5003  style->saveWidgetFont(this, font);
5004  }
5005 #endif
5006 
5007  setAttribute(Qt::WA_SetFont, font.resolve() != 0);
5008 
5009  // Determine which font is inherited from this widget's ancestors and
5010  // QApplication::font, resolve this against \a font (attributes from the
5011  // inherited font are copied over). Then propagate this font to this
5012  // widget's children.
5013  QFont naturalFont = d->naturalWidgetFont(d->inheritedFontResolveMask);
5014  QFont resolvedFont = font.resolve(naturalFont);
5015  d->setFont_helper(resolvedFont);
5016 }
double d
Definition: qnumeric_p.h:62
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_D(Class)
Definition: qglobal.h:2482
QStyle * style() const
Definition: qwidget.cpp:2742
QFont resolve(const QFont &) const
Returns a new QFont that has attributes copied from other that have not been previously set on this f...
Definition: qfont.cpp:1983
The QFont class specifies a font used for drawing text.
Definition: qfont.h:64
void saveWidgetFont(QWidget *w, const QFont &font) const
void setAttribute(Qt::WidgetAttribute, bool on=true)
Sets the attribute attribute on this widget if on is true; otherwise clears the attribute.
Definition: qwidget.cpp:11087

◆ setForegroundRole()

void QWidget::setForegroundRole ( QPalette::ColorRole  role)

Sets the foreground role of the widget to role.

The foreground role defines the color from the widget's palette that is used to draw the foreground.

If role is QPalette::NoRole, the widget uses a foreground role that contrasts with the background role.

Note that styles are free to choose any color from the palette. You can modify the palette or set a style sheet if you don't achieve the result you want with setForegroundRole().

See also
foregroundRole(), backgroundRole()

Definition at line 4773 of file qwidget.cpp.

Referenced by QTipLabel::QTipLabel().

4774 {
4775  Q_D(QWidget);
4776  d->fg_role = role;
4777  d->updateSystemBackground();
4778  d->propagatePaletteChange();
4779 }
double d
Definition: qnumeric_p.h:62
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_D(Class)
Definition: qglobal.h:2482

◆ setGeometry() [1/2]

void QWidget::setGeometry ( int  x,
int  y,
int  w,
int  h 
)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.This corresponds to setGeometry(QRect(x, y, w, h)).

Definition at line 1017 of file qwidget.h.

Referenced by QWorkspacePrivate::_q_scrollBarChanged(), QCalendarWidgetPrivate::_q_yearClicked(), QWorkspaceChild::adjustToFullscreen(), QWidgetAnimator::animate(), QApplicationPrivate::applyX11SpecificCommandLineArguments(), QWorkspace::cascade(), QColumnViewPrivate::createColumn(), QColumnViewPrivate::doLayout(), QLayoutPrivate::doResize(), QMenuBar::eventFilter(), fixToolBarOrientation(), QWorkspacePrivate::hideChild(), QProgressDialogPrivate::layout(), QTabBarPrivate::layoutTabs(), make_widget_eventUPP(), QWorkspacePrivate::minimizeWindow(), QMenuPrivate::mouseEventTaken(), QSizeGrip::mouseMoveEvent(), QWidgetResizeHandler::mouseMoveEvent(), QVistaHelper::mouseMoveEvent(), QRubberBand::move(), QVNCIntegration::moveToScreen(), QWorkspacePrivate::normalizeWindow(), parseGeometry(), QMdiAreaPrivate::place(), QWorkspacePrivate::place(), QMenu::popup(), QOpenKODEWindow::QOpenKODEWindow(), qt_mac_widget_in_menu_eventHandler(), qWinProcessConfigRequests(), QMdi::RegularTiler::rearrange(), QMdi::SimpleCascader::rearrange(), QMdi::IconTiler::rearrange(), QRubberBand::resize(), QScriptEdit::resizeEvent(), QWorkspaceChild::resizeEvent(), QBBScreen::resizeNativeWidgetWindow(), QBBScreen::resizeTopLevelWindow(), restoreGeometry(), QSplitterPrivate::setGeo(), QEglFSWindow::setGeometry(), QOpenKODEWindow::setGeometry(), QRubberBand::setGeometry(), QToolBarLayout::setGeometry(), QStackedLayout::setGeometry(), QRasterWindowSurface::setGeometry(), QAbstractItemView::setIndexWidget(), QStackedLayout::setStackingMode(), QCompleterPrivate::showPopup(), QComboBox::showPopup(), QWorkspace::tile(), QMainWindowLayout::toggleToolBarsVisible(), QETWidget::translateEmbedEvent(), QMenuPrivate::updateActionRects(), QDateTimeEditPrivate::updateEditFieldGeometry(), QAbstractSpinBoxPrivate::updateEditFieldGeometry(), QStyledItemDelegate::updateEditorGeometry(), QItemDelegate::updateEditorGeometry(), QUIKitWindow::updateGeometryAndOrientation(), QComboBoxPrivate::updateLineEditGeometry(), QDesktopWidgetPrivate::updateScreenList(), QDockAreaLayoutInfo::updateSeparatorWidgets(), QDockAreaLayout::updateSeparatorWidgets(), and QMdiAreaPrivate::updateTabBarGeometry().

1018 { setGeometry(QRect(ax, ay, aw, ah)); }
void setGeometry(int x, int y, int w, int h)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qwidget.h:1017
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58

◆ setGeometry() [2/2]

void QWidget::setGeometry ( const QRect r)

Definition at line 7213 of file qwidget.cpp.

7214 {
7215  Q_D(QWidget);
7218  if (isWindow())
7219  d->topData()->posFromMove = false;
7221  d->setGeometry_sys(r.x(), r.y(), r.width(), r.height(), true);
7222  d->setDirtyOpaqueRegion();
7223  } else {
7224  data->crect.setTopLeft(r.topLeft());
7228  }
7229 }
double d
Definition: qnumeric_p.h:62
QRect crect
Definition: qwidget.h:131
bool isWindow() const
Returns true if the widget is an independent window, otherwise returns false.
Definition: qwidget.h:945
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
QSize expandedTo(const QSize &) const
Returns a size holding the maximum width and height of this size and the given otherSize.
Definition: qsize.h:187
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
#define Q_D(Class)
Definition: qglobal.h:2482
QSize boundedTo(const QSize &) const
Returns a size holding the minimum width and height of this size and the given otherSize.
Definition: qsize.h:192
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
QSize size() const
Returns the size of the rectangle.
Definition: qrect.h:309
QWidgetData * data
Definition: qwidget.h:815
void setSize(const QSize &s)
Sets the size of the rectangle to the given size.
Definition: qrect.h:448
void setTopLeft(const QPoint &p)
Set the top-left corner of the rectangle to the given position.
Definition: qrect.h:270
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252
QSize maximumSize() const
QSize minimumSize() const
void setAttribute(Qt::WidgetAttribute, bool on=true)
Sets the attribute attribute on this widget if on is true; otherwise clears the attribute.
Definition: qwidget.cpp:11087
QPoint topLeft() const
Returns the position of the rectangle&#39;s top-left corner.
Definition: qrect.h:288

◆ setGraphicsEffect()

void QWidget::setGraphicsEffect ( QGraphicsEffect effect)

The setGraphicsEffect function is for setting the widget's graphics effect.

Sets effect as the widget's effect. If there already is an effect installed on this widget, QWidget will delete the existing effect before installing the new effect.

If effect is the installed on a different widget, setGraphicsEffect() will remove the effect from the widget and install it on this widget.

QWidget takes ownership of effect.

Note
This function will apply the effect on itself and all its children.
Graphics effects are not supported on Mac, so they will not cause any difference to the rendering of the widget.
Since
4.6
See also
graphicsEffect()

Definition at line 5517 of file qwidget.cpp.

5518 {
5519  Q_D(QWidget);
5520  if (d->graphicsEffect == effect)
5521  return;
5522 
5523  if (d->graphicsEffect) {
5524  d->invalidateBuffer(rect());
5525  delete d->graphicsEffect;
5526  d->graphicsEffect = 0;
5527  }
5528 
5529  if (effect) {
5530  // Set new effect.
5532  QGraphicsEffectSource *source = new QGraphicsEffectSource(*sourced);
5533  d->graphicsEffect = effect;
5534  effect->d_func()->setGraphicsEffectSource(source);
5535  update();
5536  }
5537 
5538  d->updateIsOpaque();
5539 }
double d
Definition: qnumeric_p.h:62
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
The QGraphicsEffectSource class represents the source on which a QGraphicsEffect is installed on...
#define Q_D(Class)
Definition: qglobal.h:2482
void update()
Updates the widget unless updates are disabled or the widget is hidden.
Definition: qwidget.cpp:10883
friend class QWidgetEffectSourcePrivate
Definition: qwidget.h:771
QRect rect() const

◆ setHidden

void QWidget::setHidden ( bool  hidden)
inlineslot

Convenience function, equivalent to setVisible(!hidden).

Definition at line 495 of file qwidget.h.

Referenced by QListWidgetItem::listWidget(), QSplitterPrivate::recalc(), and QTreeWidget::setItemHidden().

495 { setVisible(!hidden); }
virtual void setVisible(bool visible)
Definition: qwidget.cpp:7991

◆ setInputContext()

void QWidget::setInputContext ( QInputContext context)

This function sets the input context context on this widget.

Qt takes ownership of the given input context.

See also
inputContext()

Definition at line 491 of file qwidget.cpp.

492 {
493  Q_D(QWidget);
495  return;
496 
497  if (context == d->ic)
498  return;
499  if (d->ic)
500  delete d->ic;
501  d->ic = context;
502  if (d->ic)
503  d->ic->setParent(this);
504 }
double d
Definition: qnumeric_p.h:62
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_D(Class)
Definition: qglobal.h:2482
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041

◆ setInputMethodHints()

void QWidget::setInputMethodHints ( Qt::InputMethodHints  hints)

Definition at line 9736 of file qwidget.cpp.

Referenced by QInputDialog::getText(), QLineEdit::setEchoMode(), setShown(), and QGraphicsViewPrivate::updateInputMethodSensitivity().

9737 {
9738 #ifndef QT_NO_IM
9739  Q_D(QWidget);
9740  if (d->imHints == hints)
9741  return;
9742  d->imHints = hints;
9743  // Optimization to update input context only it has already been created.
9744  if (d->ic || qApp->d_func()->inputContext) {
9745  QInputContext *ic = inputContext();
9746  if (ic)
9747  ic->update();
9748  }
9749 #endif //QT_NO_IM
9750 }
double d
Definition: qnumeric_p.h:62
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_D(Class)
Definition: qglobal.h:2482
virtual void update()
This virtual function is called when a state in the focus widget has changed.
#define qApp
QInputContext * inputContext()
This function returns the QInputContext for this widget.
Definition: qwidget.cpp:474
The QInputContext class abstracts the input method dependent data and composing state.
Definition: qinputcontext.h:83

◆ setLayout()

void QWidget::setLayout ( QLayout layout)

Sets the layout manager for this widget to layout.

If there already is a layout manager installed on this widget, QWidget won't let you install another. You must first delete the existing layout manager (returned by layout()) before you can call setLayout() with the new layout.

If layout is the layout manger on a different widget, setLayout() will reparent the layout and make it the layout manager for this widget.

Example:

layout->addWidget(formWidget);
setLayout(layout);

An alternative to calling this function is to pass this widget to the layout's constructor.

The QWidget will take ownership of layout.

See also
layout(), {Layout Management}

Definition at line 10104 of file qwidget.cpp.

Referenced by QCalendarWidgetPrivate::createNavigationBar(), QPrintPreviewDialogPrivate::init(), QAbstractScrollAreaScrollBarContainer::QAbstractScrollAreaScrollBarContainer(), QBalloonTip::QBalloonTip(), QLayout::QLayout(), QMdiSubWindow::QMdiSubWindow(), QMessageBoxDetailsText::QMessageBoxDetailsText(), and QPrintPropertiesDialog::QPrintPropertiesDialog().

10105 {
10106  if (!l) {
10107  qWarning("QWidget::setLayout: Cannot set layout to 0");
10108  return;
10109  }
10110  if (layout()) {
10111  if (layout() != l)
10112  qWarning("QWidget::setLayout: Attempting to set QLayout \"%s\" on %s \"%s\", which already has a"
10113  " layout", l->objectName().toLocal8Bit().data(), metaObject()->className(),
10114  objectName().toLocal8Bit().data());
10115  return;
10116  }
10117 
10118  QObject *oldParent = l->parent();
10119  if (oldParent && oldParent != this) {
10120  if (oldParent->isWidgetType()) {
10121  // Steal the layout off a widget parent. Takes effect when
10122  // morphing laid-out container widgets in Designer.
10123  QWidget *oldParentWidget = static_cast<QWidget *>(oldParent);
10124  oldParentWidget->takeLayout();
10125  } else {
10126  qWarning("QWidget::setLayout: Attempting to set QLayout \"%s\" on %s \"%s\", when the QLayout already has a parent",
10128  objectName().toLocal8Bit().data());
10129  return;
10130  }
10131  }
10132 
10133  Q_D(QWidget);
10134  l->d_func()->topLevel = true;
10135  d->layout = l;
10136  if (oldParent != this) {
10137  l->setParent(this);
10138  l->d_func()->reparentChildWidgets(this);
10139  l->invalidate();
10140  }
10141 
10142  if (isWindow() && d->maybeTopData())
10143  d->topData()->sizeAdjusted = false;
10144 }
double d
Definition: qnumeric_p.h:62
char * data()
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:429
bool isWindow() const
Returns true if the widget is an independent window, otherwise returns false.
Definition: qwidget.h:945
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
#define Q_D(Class)
Definition: qglobal.h:2482
void setParent(QObject *)
Makes the object a child of parent.
Definition: qobject.cpp:1950
Q_CORE_EXPORT void qWarning(const char *,...)
QByteArray toLocal8Bit() const Q_REQUIRED_RESULT
Returns the local 8-bit representation of the string as a QByteArray.
Definition: qstring.cpp:4049
bool isWidgetType() const
Returns true if the object is a widget; otherwise returns false.
Definition: qobject.h:146
QObject * parent() const
Returns a pointer to the parent object.
Definition: qobject.h:273
const char * className() const
Returns the class name.
Definition: qobjectdefs.h:491
QString objectName() const
QFactoryLoader * l
QLayout * layout() const
Returns the layout manager that is installed on this widget, or 0 if no layout manager is installed...
Definition: qwidget.cpp:10073
QLayout * takeLayout()
Remove the layout from the widget.
Definition: qwidget.cpp:10153
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.

◆ setLayoutDirection()

void QWidget::setLayoutDirection ( Qt::LayoutDirection  direction)

Definition at line 5199 of file qwidget.cpp.

Referenced by QLineEdit::keyPressEvent(), and QComboBoxPrivate::updateLayoutDirection().

5200 {
5201  Q_D(QWidget);
5202 
5205  return;
5206  }
5207 
5209  d->setLayoutDirection_helper(direction);
5210 }
double d
Definition: qnumeric_p.h:62
void unsetLayoutDirection()
Definition: qwidget.cpp:5217
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_D(Class)
Definition: qglobal.h:2482
void setAttribute(Qt::WidgetAttribute, bool on=true)
Sets the attribute attribute on this widget if on is true; otherwise clears the attribute.
Definition: qwidget.cpp:11087
Qt::LayoutDirection direction

◆ setLocale()

void QWidget::setLocale ( const QLocale locale)

Definition at line 6152 of file qwidget.cpp.

6153 {
6154  Q_D(QWidget);
6155 
6157  d->setLocale_helper(locale);
6158 }
double d
Definition: qnumeric_p.h:62
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_D(Class)
Definition: qglobal.h:2482
void setAttribute(Qt::WidgetAttribute, bool on=true)
Sets the attribute attribute on this widget if on is true; otherwise clears the attribute.
Definition: qwidget.cpp:11087

◆ setMask() [1/2]

void QWidget::setMask ( const QBitmap bitmap)

Causes only the pixels of the widget for which bitmap has a corresponding 1 bit 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.

The following code shows how an image with an alpha channel can be used to generate a mask for a widget:

QLabel topLevelLabel;
QPixmap pixmap(":/images/tux.png");
topLevelLabel.setPixmap(pixmap);
topLevelLabel.setMask(pixmap.mask());

The label shown by this code is masked using the image it contains, giving the appearance that an irregularly-shaped image is being drawn directly onto the screen.

Masked widgets receive mouse events only on their visible portions.

See also
clearMask(), windowOpacity(), {Shaped Clock Example}

Definition at line 13309 of file qwidget.cpp.

Referenced by QBalloonTip::balloon(), clearMask(), QMenu::event(), QPlastiqueStyle::eventFilter(), QTipLabel::resizeEvent(), QSplitterHandle::resizeEvent(), QShapedPixmapWidget::setPixmap(), QWorkspaceChild::updateMask(), QDockAreaLayoutInfo::updateSeparatorWidgets(), QDockAreaLayout::updateSeparatorWidgets(), and QApplication::widgetAt().

13310 {
13311  setMask(QRegion(bitmap));
13312 }
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
void setMask(const QBitmap &)
Causes only the pixels of the widget for which bitmap has a corresponding 1 bit to be visible...
Definition: qwidget.cpp:13309

◆ setMask() [2/2]

void QWidget::setMask ( const QRegion region)

Causes only the parts of the widget which overlap region to be visible.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

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
windowOpacity

Definition at line 13227 of file qwidget.cpp.

13228 {
13229  Q_D(QWidget);
13230 
13231  d->createExtra();
13232  if (newMask == d->extra->mask)
13233  return;
13234 
13235 #ifndef QT_NO_BACKINGSTORE
13236  const QRegion oldMask(d->extra->mask);
13237 #endif
13238 
13239  d->extra->mask = newMask;
13240  d->extra->hasMask = !newMask.isEmpty();
13241 
13242 #ifndef QT_MAC_USE_COCOA
13244  return;
13245 #endif
13246 
13247  d->setMask_sys(newMask);
13248 
13249 #ifndef QT_NO_BACKINGSTORE
13250  if (!isVisible())
13251  return;
13252 
13253  if (!d->extra->hasMask) {
13254  // Mask was cleared; update newly exposed area.
13255  QRegion expose(rect());
13256  expose -= oldMask;
13257  if (!expose.isEmpty()) {
13258  d->setDirtyOpaqueRegion();
13259  update(expose);
13260  }
13261  return;
13262  }
13263 
13264  if (!isWindow()) {
13265  // Update newly exposed area on the parent widget.
13266  QRegion parentExpose(rect());
13267  parentExpose -= newMask;
13268  if (!parentExpose.isEmpty()) {
13269  d->setDirtyOpaqueRegion();
13270  parentExpose.translate(data->crect.topLeft());
13271  parentWidget()->update(parentExpose);
13272  }
13273 
13274  // Update newly exposed area on this widget
13275  if (!oldMask.isEmpty())
13276  update(newMask - oldMask);
13277  }
13278 #endif
13279 }
double d
Definition: qnumeric_p.h:62
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
QRect crect
Definition: qwidget.h:131
bool isWindow() const
Returns true if the widget is an independent window, otherwise returns false.
Definition: qwidget.h:945
bool isVisible() const
Definition: qwidget.h:1005
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_D(Class)
Definition: qglobal.h:2482
void update()
Updates the widget unless updates are disabled or the widget is hidden.
Definition: qwidget.cpp:10883
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
QWidgetData * data
Definition: qwidget.h:815
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
QRect rect() const
QPoint topLeft() const
Returns the position of the rectangle&#39;s top-left corner.
Definition: qrect.h:288

◆ setMaximumHeight()

void QWidget::setMaximumHeight ( int  maxh)

Definition at line 4352 of file qwidget.cpp.

Referenced by QStyleSheetStyle::setGeometry().

4353 {
4354  Q_D(QWidget);
4355  d->createExtra();
4356  uint expl = d->extra->explicitMaxSize | (h == QWIDGETSIZE_MAX ? 0 : Qt::Vertical);
4358  d->extra->explicitMaxSize = expl;
4359 }
double d
Definition: qnumeric_p.h:62
#define QWIDGETSIZE_MAX
Defines the maximum size for a QWidget object.
Definition: qwidget.h:1087
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
void setMaximumSize(const QSize &)
Definition: qwidget.h:972
#define Q_D(Class)
Definition: qglobal.h:2482
int width() const
unsigned int uint
Definition: qglobal.h:996
QSize maximumSize() const

◆ setMaximumSize() [1/2]

void QWidget::setMaximumSize ( const QSize s)
inline

◆ setMaximumSize() [2/2]

void QWidget::setMaximumSize ( int  maxw,
int  maxh 
)

This function corresponds to setMaximumSize(QSize(maxw, maxh)).

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Sets the maximum width to maxw and the maximum height to maxh.

Definition at line 4201 of file qwidget.cpp.

4202 {
4203  Q_D(QWidget);
4204  if (!d->setMaximumSize_helper(maxw, maxh))
4205  return;
4206 
4207  if (isWindow())
4208  d->setConstraints_sys();
4209  if (maxw < width() || maxh < height()) {
4210  bool resized = testAttribute(Qt::WA_Resized);
4211  resize(qMin(maxw,width()), qMin(maxh,height()));
4212  setAttribute(Qt::WA_Resized, resized); //not a user resize
4213  }
4214 
4215 #ifndef QT_NO_GRAPHICSVIEW
4216  if (d->extra) {
4217  if (d->extra->proxyWidget)
4218  d->extra->proxyWidget->setMaximumSize(maxw, maxh);
4219  }
4220 #endif
4221 
4222  d->updateGeometry_helper(d->extra->minw == d->extra->maxw && d->extra->minh == d->extra->maxh);
4223 }
double d
Definition: qnumeric_p.h:62
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
bool isWindow() const
Returns true if the widget is an independent window, otherwise returns false.
Definition: qwidget.h:945
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_D(Class)
Definition: qglobal.h:2482
int height() const
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
int width() const
void resize(int w, int h)
This corresponds to resize(QSize(w, h)).
Definition: qwidget.h:1014
void setAttribute(Qt::WidgetAttribute, bool on=true)
Sets the attribute attribute on this widget if on is true; otherwise clears the attribute.
Definition: qwidget.cpp:11087

◆ setMaximumWidth()

void QWidget::setMaximumWidth ( int  maxw)

Definition at line 4343 of file qwidget.cpp.

Referenced by QBalloonTip::QBalloonTip(), QExpandingLineEdit::resizeToContents(), and QStyleSheetStyle::setGeometry().

4344 {
4345  Q_D(QWidget);
4346  d->createExtra();
4347  uint expl = d->extra->explicitMaxSize | (w == QWIDGETSIZE_MAX ? 0 : Qt::Horizontal);
4349  d->extra->explicitMaxSize = expl;
4350 }
double d
Definition: qnumeric_p.h:62
#define QWIDGETSIZE_MAX
Defines the maximum size for a QWidget object.
Definition: qwidget.h:1087
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
void setMaximumSize(const QSize &)
Definition: qwidget.h:972
#define Q_D(Class)
Definition: qglobal.h:2482
int height() const
unsigned int uint
Definition: qglobal.h:996
QSize maximumSize() const

◆ setMinimumHeight()

void QWidget::setMinimumHeight ( int  minh)

Definition at line 4334 of file qwidget.cpp.

Referenced by QColorShower::QColorShower(), QStyleSheetStyle::setGeometry(), and QWorkspaceChild::showShaded().

4335 {
4336  Q_D(QWidget);
4337  d->createExtra();
4338  uint expl = d->extra->explicitMinSize | (h ? Qt::Vertical : 0);
4340  d->extra->explicitMinSize = expl;
4341 }
double d
Definition: qnumeric_p.h:62
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
void setMinimumSize(const QSize &)
Definition: qwidget.h:969
#define Q_D(Class)
Definition: qglobal.h:2482
int width() const
unsigned int uint
Definition: qglobal.h:996
QSize minimumSize() const

◆ setMinimumSize() [1/2]

void QWidget::setMinimumSize ( const QSize s)
inline

◆ setMinimumSize() [2/2]

void QWidget::setMinimumSize ( int  minw,
int  minh 
)

This function corresponds to setMinimumSize(QSize(minw, minh)).

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Sets the minimum width to minw and the minimum height to minh.

Definition at line 4138 of file qwidget.cpp.

4139 {
4140  Q_D(QWidget);
4141  if (!d->setMinimumSize_helper(minw, minh))
4142  return;
4143 
4144  if (isWindow())
4145  d->setConstraints_sys();
4146  if (minw > width() || minh > height()) {
4147  bool resized = testAttribute(Qt::WA_Resized);
4148  bool maximized = isMaximized();
4149  resize(qMax(minw,width()), qMax(minh,height()));
4150  setAttribute(Qt::WA_Resized, resized); //not a user resize
4151  if (maximized)
4153  }
4154 #ifndef QT_NO_GRAPHICSVIEW
4155  if (d->extra) {
4156  if (d->extra->proxyWidget)
4157  d->extra->proxyWidget->setMinimumSize(minw, minh);
4158  }
4159 #endif
4160  d->updateGeometry_helper(d->extra->minw == d->extra->maxw && d->extra->minh == d->extra->maxh);
4161 }
double d
Definition: qnumeric_p.h:62
bool isWindow() const
Returns true if the widget is an independent window, otherwise returns false.
Definition: qwidget.h:945
uint window_state
Definition: qwidget.h:120
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
bool maximized
whether this widget is maximized
Definition: qwidget.h:193
#define Q_D(Class)
Definition: qglobal.h:2482
int height() const
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
int width() const
QWidgetData * data
Definition: qwidget.h:815
bool isMaximized() const
Definition: qwidget.cpp:3074
void resize(int w, int h)
This corresponds to resize(QSize(w, h)).
Definition: qwidget.h:1014
void setAttribute(Qt::WidgetAttribute, bool on=true)
Sets the attribute attribute on this widget if on is true; otherwise clears the attribute.
Definition: qwidget.cpp:11087

◆ setMinimumWidth()

void QWidget::setMinimumWidth ( int  minw)

Definition at line 4325 of file qwidget.cpp.

Referenced by QColumnViewPrivate::createColumn(), QColumnView::initializeColumn(), QColorShower::QColorShower(), QScriptDebuggerCodeFinderWidget::QScriptDebuggerCodeFinderWidget(), QStyleSheetStyle::setGeometry(), QColumnViewPreviewColumn::setPreviewWidget(), and QExpandingLineEdit::updateMinimumWidth().

4326 {
4327  Q_D(QWidget);
4328  d->createExtra();
4329  uint expl = d->extra->explicitMinSize | (w ? Qt::Horizontal : 0);
4331  d->extra->explicitMinSize = expl;
4332 }
double d
Definition: qnumeric_p.h:62
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
void setMinimumSize(const QSize &)
Definition: qwidget.h:969
#define Q_D(Class)
Definition: qglobal.h:2482
int height() const
unsigned int uint
Definition: qglobal.h:996
QSize minimumSize() const

◆ setMouseTracking()

void QWidget::setMouseTracking ( bool  enable)
inline

◆ setPalette()

void QWidget::setPalette ( const QPalette palette)

Use the single-argument overload instead.

Definition at line 4858 of file qwidget.cpp.

Referenced by QFocusFrame::eventFilter(), QCalToolButton::paintEvent(), QMacStyle::polish(), QWindowsVistaStyle::polish(), QBalloonTip::QBalloonTip(), QMacNativeWidget::QMacNativeWidget(), QTipLabel::QTipLabel(), QWhatsThat::QWhatsThat(), QWizardPrivate::recreateLayout(), QToolTip::setPalette(), QStyleSheetStyle::setPalette(), QMacStyle::unpolish(), QStyleSheetStyle::unsetPalette(), QToolBoxPrivate::updateTabs(), QComboBoxPrivate::updateViewContainerPaletteAndOpacity(), QScriptDebuggerLocalsItemDelegate::validateInput(), and QScriptBreakpointsItemDelegate::validateInput().

4859 {
4860  Q_D(QWidget);
4861  setAttribute(Qt::WA_SetPalette, palette.resolve() != 0);
4862 
4863  // Determine which palette is inherited from this widget's ancestors and
4864  // QApplication::palette, resolve this against \a palette (attributes from
4865  // the inherited palette are copied over this widget's palette). Then
4866  // propagate this palette to this widget's children.
4867  QPalette naturalPalette = d->naturalWidgetPalette(d->inheritedPaletteResolveMask);
4868  QPalette resolvedPalette = palette.resolve(naturalPalette);
4869  d->setPalette_helper(resolvedPalette);
4870 }
double d
Definition: qnumeric_p.h:62
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_D(Class)
Definition: qglobal.h:2482
void setAttribute(Qt::WidgetAttribute, bool on=true)
Sets the attribute attribute on this widget if on is true; otherwise clears the attribute.
Definition: qwidget.cpp:11087
QPalette resolve(const QPalette &) const
Returns a new QPalette that has attributes copied from other.
Definition: qpalette.cpp:1101
The QPalette class contains color groups for each widget state.
Definition: qpalette.h:61

◆ setParent() [1/2]

void QWidget::setParent ( QWidget parent)

Sets the parent of the widget to parent, and resets the window flags.

The widget is moved to position (0, 0) in its new parent.

If the new parent widget is in a different window, 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. If one of the moved widgets had keyboard focus, setParent() calls clearFocus() for that widget.

If the new parent widget is in the same window as the old parent, setting the parent doesn't change the tab order or keyboard focus.

If the "new" parent widget is the old parent widget, this function does nothing.

Note
The widget becomes invisible as part of changing its parent, even if it was previously visible. You must call show() to make the widget visible again.
Warning
It is very unlikely that you will ever need this function. If you have a widget that changes its content dynamically, it is far easier to use QStackedWidget .
See also
setWindowFlags()

Definition at line 10479 of file qwidget.cpp.

Referenced by QMenuPrivate::QMacMenuPrivate::addAction(), QDialogButtonBox::addButton(), QLayout::addChildWidget(), QMdiArea::addSubWindow(), QAbstractScrollAreaScrollBarContainer::addWidget(), QMdiAreaPrivate::appendChild(), QColumnViewPrivate::createColumn(), QWorkspacePrivate::insertIcon(), QMainWindowLayout::insertIntoMacToolbar(), QSplitterPrivate::insertWidget_helper(), QWidgetPrivate::isBackgroundInherited(), QDialog::open(), QGtkStylePrivate::openDirectory(), QGtkStylePrivate::openFilename(), QGtkStylePrivate::openFilenames(), QPrintDialogPrivate::openWindowsPrintDialogModally(), q_createNativeChildrenAndSetParent(), qt_win_get_existing_directory(), qt_win_get_open_file_name(), qt_win_get_open_file_names(), qt_win_get_save_file_name(), qt_x11_recreateWidget(), QTornOffMenu::QTornOffMenu(), QWorkspaceChild::QWorkspaceChild(), QMdiSubWindowPrivate::removeBaseWidget(), QDialogButtonBox::removeButton(), QMdi::ControlContainer::removeButtonsFromMenuBar(), QMainWindowLayout::removeFromMacToolbar(), QLayoutPrivate::reparentChildWidgets(), QAbstractScrollAreaPrivate::replaceScrollBar(), QDeclarativeVME::run(), QGtkStylePrivate::saveFilename(), QWizard::setButton(), QProgressDialog::setCancelButton(), QAbstractScrollArea::setCornerWidget(), QMenuBar::setCornerWidget(), QTabWidget::setCornerWidget(), QDialog::setExtension(), QAbstractItemView::setIndexWidget(), QComboBoxPrivateContainer::setItemView(), QProgressDialog::setLabel(), QWizard::setPage(), QCompleter::setPopup(), QColumnViewPrivate::setPreviewWidget(), QDeclarativeView::setRootObject(), QMdiSubWindowPrivate::setSizeGrip(), QMdiSubWindow::setSystemMenu(), QTabWidget::setTabBar(), QTabBar::setTabButton(), QMdiArea::setupViewport(), QScrollArea::setWidget(), QMdiSubWindow::setWidget(), setWindowFlags(), QMessageBox::setWindowModality(), and QScrollArea::takeWidget().

10480 {
10481  if (parent == parentWidget())
10482  return;
10484 }
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
void setParent(QWidget *parent)
Sets the parent of the widget to parent, and resets the window flags.
Definition: qwidget.cpp:10479
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
Qt::WindowFlags windowFlags() const
Window flags are a combination of a type (e.
Definition: qwidget.h:939

◆ setParent() [2/2]

void QWidget::setParent ( QWidget parent,
Qt::WindowFlags  f 
)

This function also takes widget flags, f as an argument.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 10495 of file qwidget.cpp.

10496 {
10497  Q_D(QWidget);
10498  d->inSetParent = true;
10499  bool resized = testAttribute(Qt::WA_Resized);
10500  bool wasCreated = testAttribute(Qt::WA_WState_Created);
10501  QWidget *oldtlw = window();
10502 
10503  QWidget *desktopWidget = 0;
10504  if (parent && parent->windowType() == Qt::Desktop)
10505  desktopWidget = parent;
10506  bool newParent = (parent != parentWidget()) || !wasCreated || desktopWidget;
10507 
10508 #if defined(Q_WS_X11) || defined(Q_WS_WIN) || defined(Q_WS_MAC) || defined(Q_OS_SYMBIAN)
10509  if (newParent && parent && !desktopWidget) {
10511 #if defined(Q_WS_MAC) && defined(QT_MAC_USE_COCOA)
10512  // On Mac, toolbars inside the unified title bar will never overlap with
10513  // siblings in the content view. So we skip enforce native siblings in that case
10514  && !d->isInUnifiedToolbar && parentWidget() && parentWidget()->isWindow()
10515 #endif // Q_WS_MAC && QT_MAC_USE_COCOA
10516  )
10517  parent->d_func()->enforceNativeChildren();
10518  else if (parent->d_func()->nativeChildrenForced() || parent->testAttribute(Qt::WA_PaintOnScreen))
10520  }
10521 #endif
10522 
10523  if (wasCreated) {
10525  hide();
10527  }
10528  if (newParent) {
10530  QApplication::sendEvent(this, &e);
10531  }
10532  }
10533  if (newParent && isAncestorOf(focusWidget()))
10534  focusWidget()->clearFocus();
10535 
10536  QTLWExtra *oldTopExtra = window()->d_func()->maybeTopData();
10537  QWidgetBackingStoreTracker *oldBsTracker = oldTopExtra ? &oldTopExtra->backingStore : 0;
10538 
10539  d->setParent_sys(parent, f);
10540 
10541  QTLWExtra *topExtra = window()->d_func()->maybeTopData();
10542  QWidgetBackingStoreTracker *bsTracker = topExtra ? &topExtra->backingStore : 0;
10543  if (oldBsTracker && oldBsTracker != bsTracker)
10544  oldBsTracker->unregisterWidgetSubtree(this);
10545 
10546  if (desktopWidget)
10547  parent = 0;
10548 
10549 #ifdef Q_BACKINGSTORE_SUBSURFACES
10550  QTLWExtra *extra = d->maybeTopData();
10551  QWindowSurface *windowSurface = (extra ? extra->windowSurface : 0);
10552  if (newParent && windowSurface) {
10553  QWidgetBackingStore *oldBs = oldtlw->d_func()->maybeBackingStore();
10554  if (oldBs)
10555  oldBs->subSurfaces.removeAll(windowSurface);
10556 
10557  if (parent) {
10558  QWidgetBackingStore *newBs = parent->d_func()->maybeBackingStore();
10559  if (newBs)
10560  newBs->subSurfaces.append(windowSurface);
10561  }
10562  }
10563 #endif
10564 
10565  if (QWidgetBackingStore *oldBs = oldtlw->d_func()->maybeBackingStore()) {
10566  if (newParent)
10567  oldBs->removeDirtyWidget(this);
10568  // Move the widget and all its static children from
10569  // the old backing store to the new one.
10570  oldBs->moveStaticWidgets(this);
10571  }
10572 
10576  create();
10577 
10578  d->reparentFocusWidgets(oldtlw);
10579  setAttribute(Qt::WA_Resized, resized);
10581  && (!parent || !parent->testAttribute(Qt::WA_StyleSheet))) {
10582  d->resolveFont();
10583  d->resolvePalette();
10584  }
10585  d->resolveLayoutDirection();
10586  d->resolveLocale();
10587 
10588  // Note: GL widgets under WGL or EGL will always need a ParentChange
10589  // event to handle recreation/rebinding of the GL context, hence the
10590  // (f & Qt::MSWindowsOwnDC) clause (which is set on QGLWidgets on all
10591  // platforms).
10592  if (newParent
10593 #if defined(Q_WS_WIN) || defined(QT_OPENGL_ES)
10594  || (f & Qt::MSWindowsOwnDC)
10595 #endif
10596  ) {
10597  // propagate enabled updates enabled state to non-windows
10598  if (!isWindow()) {
10600  d->setEnabled_helper(parent ? parent->isEnabled() : true);
10602  d->setUpdatesEnabled_helper(parent ? parent->updatesEnabled() : true);
10603  }
10604  d->inheritStyle();
10605 
10606  // send and post remaining QObject events
10607  if (parent && d->sendChildEvents) {
10609  QApplication::sendEvent(parent, &e);
10610 #ifdef QT3_SUPPORT
10611  if (parent->d_func()->pendingChildInsertedEvents.isEmpty()) {
10612  QApplication::postEvent(parent,
10613  new QEvent(QEvent::ChildInsertedRequest),
10615  }
10616  parent->d_func()->pendingChildInsertedEvents.append(this);
10617 #endif
10618  }
10619 
10620 //### already hidden above ---> must probably do something smart on the mac
10621 // #ifdef Q_WS_MAC
10622 // extern bool qt_mac_is_macdrawer(const QWidget *); //qwidget_mac.cpp
10623 // if(!qt_mac_is_macdrawer(q)) //special case
10624 // q->setAttribute(Qt::WA_WState_Hidden);
10625 // #else
10626 // q->setAttribute(Qt::WA_WState_Hidden);
10627 //#endif
10628 
10629  if (parent && d->sendChildEvents && d->polished) {
10631  QCoreApplication::sendEvent(parent, &e);
10632  }
10633 
10635  QApplication::sendEvent(this, &e);
10636  }
10637 
10638  if (!wasCreated) {
10639  if (isWindow() || parentWidget()->isVisible())
10643  }
10644 
10645  d->updateIsOpaque();
10646 
10647 #ifndef QT_NO_GRAPHICSVIEW
10648  // Embed the widget into a proxy if the parent is embedded.
10649  // ### Doesn't handle reparenting out of an embedded widget.
10650  if (oldtlw->graphicsProxyWidget()) {
10651  if (QGraphicsProxyWidget *ancestorProxy = d->nearestGraphicsProxyWidget(oldtlw))
10652  ancestorProxy->d_func()->unembedSubWindow(this);
10653  }
10654  if (isWindow() && parent && !graphicsProxyWidget() && !bypassGraphicsProxyWidget(this)) {
10655  if (QGraphicsProxyWidget *ancestorProxy = d->nearestGraphicsProxyWidget(parent))
10656  ancestorProxy->d_func()->embedSubWindow(this);
10657  }
10658 #endif
10659 
10660  d->inSetParent = false;
10661 }
double d
Definition: qnumeric_p.h:62
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
QWidget * focusWidget() const
Returns the last child of this widget that setFocus had been called on.
Definition: qwidget.cpp:6863
bool isWindow() const
Returns true if the widget is an independent window, otherwise returns false.
Definition: qwidget.h:945
static void postEvent(QObject *receiver, QEvent *event)
Adds the event event, with the object receiver as the receiver of the event, to an event queue and re...
bool isVisible() const
Definition: qwidget.h:1005
QWindowSurface * windowSurface
Definition: qwidget_p.h:167
#define Q_WS_WIN
Defined on Windows.
Definition: qglobal.h:921
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
static bool testAttribute(uint flag)
void removeDirtyWidget(QWidget *w)
QGraphicsProxyWidget * graphicsProxyWidget() const
Returns the proxy widget for the corresponding embedded widget in a graphics view; otherwise returns ...
Definition: qwidget.cpp:12939
static bool bypassGraphicsProxyWidget(const QWidget *p)
Returns true if p or any of its parents enable the Qt::BypassGraphicsProxyWidget window flag...
Definition: qwidget_p.h:353
#define Q_D(Class)
Definition: qglobal.h:2482
Class which allows tracking of which widgets are using a given backing store.
Definition: qwidget_p.h:118
void clearFocus()
Takes keyboard input focus from the widget.
Definition: qwidget.cpp:6757
bool updatesEnabled
whether updates are enabled
Definition: qwidget.h:190
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
#define qApp
QWindowSurface * windowSurface() const
Returns the QWindowSurface this widget will be drawn into.
Definition: qwidget.cpp:12819
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
void create(WId=0, bool initializeWindow=true, bool destroyOldWindow=true)
Creates a new widget window if window is 0, otherwise sets the widget&#39;s window to window...
Definition: qwidget.cpp:1454
The QWindowSurface class provides the drawing area for top-level windows.
bool isEnabled() const
Definition: qwidget.h:948
void hide()
Hides the widget.
Definition: qwidget.h:501
The QGraphicsProxyWidget class provides a proxy layer for embedding a QWidget in a QGraphicsScene...
The QChildEvent class contains event parameters for child object events.
Definition: qcoreevent.h:353
void moveStaticWidgets(QWidget *reparented)
bool isAncestorOf(const QWidget *child) const
Returns true if this widget is a parent, (or grandparent and so on to any level), of the given child...
Definition: qwidget.cpp:8573
void setAttribute(Qt::WidgetAttribute, bool on=true)
Sets the attribute attribute on this widget if on is true; otherwise clears the attribute.
Definition: qwidget.cpp:11087
QWidget * window() const
Returns the window for this widget, i.e.
Definition: qwidget.cpp:4492
Qt::WindowType windowType() const
Returns the window type of this widget.
Definition: qwidget.h:937
QWidgetBackingStoreTracker backingStore
Definition: qwidget_p.h:166
The QEvent class is the base class of all event classes.
Definition: qcoreevent.h:56

◆ setShortcutAutoRepeat()

void QWidget::setShortcutAutoRepeat ( int  id,
bool  enable = true 
)

If enable is true, auto repeat of the shortcut with the given id is enabled; otherwise it is disabled.

Since
4.2
See also
grabShortcut() releaseShortcut()

Definition at line 11808 of file qwidget.cpp.

11809 {
11810  Q_ASSERT(qApp);
11811  if (id)
11812  qApp->d_func()->shortcutMap.setShortcutAutoRepeat(enable, id, this, 0);
11813 }
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define qApp

◆ setShortcutEnabled()

void QWidget::setShortcutEnabled ( int  id,
bool  enable = true 
)

If enable is true, the shortcut with the given id is enabled; otherwise the shortcut is disabled.

Warning
You should not normally need to use this function since Qt's shortcut system enables/disables shortcuts automatically as widgets become hidden/visible and gain or lose focus. It is best to use QAction or QShortcut to handle shortcuts, since they are easier to use than this low-level function.
See also
grabShortcut() releaseShortcut()

Definition at line 11790 of file qwidget.cpp.

Referenced by QTabBar::setTabEnabled(), and QTabBar::setTabText().

11791 {
11792  Q_ASSERT(qApp);
11793  if (id)
11794  qApp->d_func()->shortcutMap.setShortcutEnabled(enable, id, this, 0);
11795 }
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define qApp

◆ setShown

void QWidget::setShown ( bool  shown)
inlineslot

Use setVisible(shown) instead.

Definition at line 502 of file qwidget.h.

502 { setVisible(shown); }
virtual void setVisible(bool visible)
Definition: qwidget.cpp:7991

◆ setSizeIncrement() [1/2]

void QWidget::setSizeIncrement ( const QSize s)
inline

Definition at line 975 of file qwidget.h.

976 { setSizeIncrement(s.width(),s.height()); }
void setSizeIncrement(const QSize &)
Definition: qwidget.h:975
int width() const
Returns the width.
Definition: qsize.h:126
int height() const
Returns the height.
Definition: qsize.h:129

◆ setSizeIncrement() [2/2]

void QWidget::setSizeIncrement ( int  w,
int  h 
)

Sets the x (width) size increment to w and the y (height) size increment to h.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 4234 of file qwidget.cpp.

4235 {
4236  Q_D(QWidget);
4237  d->createTLExtra();
4238  QTLWExtra* x = d->topData();
4239  if (x->incw == w && x->inch == h)
4240  return;
4241  x->incw = w;
4242  x->inch = h;
4243  if (isWindow())
4244  d->setConstraints_sys();
4245 }
double d
Definition: qnumeric_p.h:62
bool isWindow() const
Returns true if the widget is an independent window, otherwise returns false.
Definition: qwidget.h:945
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_D(Class)
Definition: qglobal.h:2482
short inch
Definition: qwidget_p.h:177
short incw
Definition: qwidget_p.h:177
int x() const

◆ setSizePolicy() [1/2]

void QWidget::setSizePolicy ( QSizePolicy  policy)

Definition at line 10198 of file qwidget.cpp.

Referenced by QAbstractScrollAreaScrollBarContainer::addWidget(), QMdi::ControllerWidget::ControllerWidget(), QCalendarWidgetPrivate::createNavigationBar(), DetailButton::DetailButton(), QInputDialogPrivate::ensureLayout(), QSplitterPrivate::findWidget(), QTabWidgetPrivate::init(), QBalloonTip::QBalloonTip(), QCalendarWidget::QCalendarWidget(), QColorPicker::QColorPicker(), QColorWell::QColorWell(), QComboBoxPrivateScroller::QComboBoxPrivateScroller(), QDeclarativeView::QDeclarativeView(), QMDIControl::QMDIControl(), QToolBarExtension::QToolBarExtension(), QToolBarSeparator::QToolBarSeparator(), QToolBoxButton::QToolBoxButton(), QWizardHeader::QWizardHeader(), QWorkspaceTitleBar::QWorkspaceTitleBar(), QX11EmbedContainer::QX11EmbedContainer(), QX11EmbedWidget::QX11EmbedWidget(), QFrame::setFrameStyle(), QComboBoxPrivateContainer::setItemView(), QSplitter::setOrientation(), QToolBar::setOrientation(), QProgressBar::setOrientation(), QAbstractSlider::setOrientation(), QSplitter::setStretchFactor(), QMainWindow::statusBar(), and QCoreFuriCuri::timerEvent().

10199 {
10200  Q_D(QWidget);
10202  if (policy == d->size_policy)
10203  return;
10204  d->size_policy = policy;
10205 
10206 #ifndef QT_NO_GRAPHICSVIEW
10207  if (QWExtra *extra = d->extra) {
10208  if (extra->proxyWidget)
10209  extra->proxyWidget->setSizePolicy(policy);
10210  }
10211 #endif
10212 
10213  updateGeometry();
10214 
10215  if (isWindow() && d->maybeTopData())
10216  d->topData()->sizeAdjusted = false;
10217 }
double d
Definition: qnumeric_p.h:62
bool isWindow() const
Returns true if the widget is an independent window, otherwise returns false.
Definition: qwidget.h:945
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_D(Class)
Definition: qglobal.h:2482
void setAttribute(Qt::WidgetAttribute, bool on=true)
Sets the attribute attribute on this widget if on is true; otherwise clears the attribute.
Definition: qwidget.cpp:11087
void updateGeometry()
Notifies the layout system that this widget has changed and may need to change geometry.
Definition: qwidget.cpp:10372

◆ setSizePolicy() [2/2]

void QWidget::setSizePolicy ( QSizePolicy::Policy  horizontal,
QSizePolicy::Policy  vertical 
)
inline

Sets the size policy of the widget to horizontal and vertical, with standard stretch and no height-for-width.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

See also
QSizePolicy::QSizePolicy()

Definition at line 1038 of file qwidget.h.

1039 { setSizePolicy(QSizePolicy(hor, ver)); }
void setSizePolicy(QSizePolicy)
Definition: qwidget.cpp:10198

◆ setStatusTip()

void QWidget::setStatusTip ( const QString s)

Definition at line 11629 of file qwidget.cpp.

Referenced by QToolButton::QToolButton(), QToolButton::setDefaultAction(), QListWidgetItem::statusTip(), and QHeaderView::viewportEvent().

11630 {
11631  Q_D(QWidget);
11632  d->statusTip = s;
11633 }
double d
Definition: qnumeric_p.h:62
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_D(Class)
Definition: qglobal.h:2482

◆ setStyle()

void QWidget::setStyle ( QStyle style)

Sets the widget's GUI style to style.

The ownership of the style object is not transferred.

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.

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.
Qt style sheets are currently not supported for custom QStyle subclasses. We plan to address this in some future release.
See also
style(), QStyle, QApplication::style(), QApplication::setStyle()

Definition at line 2772 of file qwidget.cpp.

Referenced by QDialogButtonBoxPrivate::createButton(), QWizardPrivate::ensureButton(), QWidgetPrivate::inheritStyle(), and QWizardPrivate::QWizardPrivate().

2773 {
2774  Q_D(QWidget);
2775  setAttribute(Qt::WA_SetStyle, style != 0);
2776  d->createExtra();
2777 #ifndef QT_NO_STYLE_STYLESHEET
2778  if (QStyleSheetStyle *proxy = qobject_cast<QStyleSheetStyle *>(style)) {
2779  //if for some reason someone try to set a QStyleSheetStyle, ref it
2780  //(this may happen for exemple in QButtonDialogBox which propagates its style)
2781  proxy->ref();
2782  d->setStyle_helper(style, false);
2783  } else if (qobject_cast<QStyleSheetStyle *>(d->extra->style) || !qApp->styleSheet().isEmpty()) {
2784  // if we have an application stylesheet or have a proxy already, propagate
2785  d->setStyle_helper(new QStyleSheetStyle(style), true);
2786  } else
2787 #endif
2788  d->setStyle_helper(style, false);
2789 }
double d
Definition: qnumeric_p.h:62
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_D(Class)
Definition: qglobal.h:2482
#define qApp
void setAttribute(Qt::WidgetAttribute, bool on=true)
Sets the attribute attribute on this widget if on is true; otherwise clears the attribute.
Definition: qwidget.cpp:11087
friend class QStyleSheetStyle
Definition: qwidget.h:765

◆ setStyleSheet

void QWidget::setStyleSheet ( const QString styleSheet)
slot

Definition at line 2709 of file qwidget.cpp.

Referenced by QTipLabel::placeTip(), QScriptDebuggerConsoleWidget::QScriptDebuggerConsoleWidget(), QScriptDebugOutputWidget::QScriptDebugOutputWidget(), and QApplication::setStyle().

2710 {
2711  Q_D(QWidget);
2712  d->createExtra();
2713 
2714  QStyleSheetStyle *proxy = qobject_cast<QStyleSheetStyle *>(d->extra->style);
2715  d->extra->styleSheet = styleSheet;
2716  if (styleSheet.isEmpty()) { // stylesheet removed
2717  if (!proxy)
2718  return;
2719 
2720  d->inheritStyle();
2721  return;
2722  }
2723 
2724  if (proxy) { // style sheet update
2725  proxy->repolish(this);
2726  return;
2727  }
2728 
2730  d->setStyle_helper(new QStyleSheetStyle(d->extra->style), true);
2731  } else {
2732  d->setStyle_helper(new QStyleSheetStyle(0), true);
2733  }
2734 }
double d
Definition: qnumeric_p.h:62
QString styleSheet() const
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
T * qobject_cast(QObject *object)
Definition: qobject.h:375
#define Q_D(Class)
Definition: qglobal.h:2482
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
friend class QStyleSheetStyle
Definition: qwidget.h:765
void repolish(QWidget *widget)

◆ setTabOrder()

void QWidget::setTabOrder ( QWidget first,
QWidget second 
)
static

Puts the second widget after the first widget in the focus order.

Note that since the tab order of the second widget is changed, you should order a chain 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

not like this:

// WRONG
setTabOrder(c, d); // c to d
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.

See also
setFocusPolicy(), setFocusProxy(), {Keyboard Focus}

Definition at line 6975 of file qwidget.cpp.

Referenced by QAbstractItemViewPrivate::editor(), QDialogButtonBoxPrivate::layoutButtons(), and QWizardPrivate::setButtonLayout().

6976 {
6977  if (!first || !second || first->focusPolicy() == Qt::NoFocus || second->focusPolicy() == Qt::NoFocus)
6978  return;
6979 
6980  if (first->window() != second->window()) {
6981  qWarning("QWidget::setTabOrder: 'first' and 'second' must be in the same window");
6982  return;
6983  }
6984 
6985  QWidget *fp = first->focusProxy();
6986  if (fp) {
6987  // If first is redirected, set first to the last child of first
6988  // that can take keyboard focus so that second is inserted after
6989  // that last child, and the focus order within first is (more
6990  // likely to be) preserved.
6991  QList<QWidget *> l = first->findChildren<QWidget *>();
6992  for (int i = l.size()-1; i >= 0; --i) {
6993  QWidget * next = l.at(i);
6994  if (next->window() == fp->window()) {
6995  fp = next;
6996  if (fp->focusPolicy() != Qt::NoFocus)
6997  break;
6998  }
6999  }
7000  first = fp;
7001  }
7002 
7003  if (fp == second)
7004  return;
7005 
7006  if (QWidget *sp = second->focusProxy())
7007  second = sp;
7008 
7009 // QWidget *fp = first->d_func()->focus_prev;
7010  QWidget *fn = first->d_func()->focus_next;
7011 
7012  if (fn == second || first == second)
7013  return;
7014 
7015  QWidget *sp = second->d_func()->focus_prev;
7016  QWidget *sn = second->d_func()->focus_next;
7017 
7018  fn->d_func()->focus_prev = second;
7019  first->d_func()->focus_next = second;
7020 
7021  second->d_func()->focus_next = fn;
7022  second->d_func()->focus_prev = first;
7023 
7024  sp->d_func()->focus_next = sn;
7025  sn->d_func()->focus_prev = sp;
7026 
7027 
7028  Q_ASSERT(first->d_func()->focus_next->d_func()->focus_prev == first);
7029  Q_ASSERT(first->d_func()->focus_prev->d_func()->focus_next == first);
7030 
7031  Q_ASSERT(second->d_func()->focus_next->d_func()->focus_prev == second);
7032  Q_ASSERT(second->d_func()->focus_prev->d_func()->focus_next == second);
7033 }
Qt::FocusPolicy focusPolicy
the way the widget accepts keyboard focus
Definition: qwidget.h:187
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
QWidget * focusProxy() const
Returns the focus proxy, or 0 if there is no focus proxy.
Definition: qwidget.cpp:6561
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
Q_CORE_EXPORT void qWarning(const char *,...)
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
QFactoryLoader * l
QWidget * window() const
Returns the window for this widget, i.e.
Definition: qwidget.cpp:4492
QList< T > findChildren(const QString &aName=QString()) const
Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects.
Definition: qobject.h:162

◆ setToolTip()

void QWidget::setToolTip ( const QString s)

Definition at line 11600 of file qwidget.cpp.

Referenced by CloseButton::CloseButton(), QToolTip::hideText(), QmlJSDebugger::QDeclarativeViewInspector::mouseMoveEvent(), QToolButton::QToolButton(), QToolButton::setDefaultAction(), QToolBoxPrivate::Page::setToolTip(), and QListWidgetItem::toolTip().

11601 {
11602  Q_D(QWidget);
11603  d->toolTip = s;
11604 
11607 }
double d
Definition: qnumeric_p.h:62
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_D(Class)
Definition: qglobal.h:2482
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
bool event(QEvent *)
This is the main event handler; it handles event event.
Definition: qwidget.cpp:8636
The QEvent class is the base class of all event classes.
Definition: qcoreevent.h:56

◆ setUpdatesEnabled()

void QWidget::setUpdatesEnabled ( bool  enable)

Definition at line 7670 of file qwidget.cpp.

Referenced by QScriptDebuggerPrivate::handleResponse(), QAccessibleItemRow::navigate(), QRollEffect::scroll(), QStackedLayout::setCurrentIndex(), and QComboBox::showPopup().

7671 {
7672  Q_D(QWidget);
7674  d->setUpdatesEnabled_helper(enable);
7675 }
double d
Definition: qnumeric_p.h:62
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_D(Class)
Definition: qglobal.h:2482
void setAttribute(Qt::WidgetAttribute, bool on=true)
Sets the attribute attribute on this widget if on is true; otherwise clears the attribute.
Definition: qwidget.cpp:11087

◆ setupUi()

QWidget::setupUi ( QWidget widget)

Sets up the user interface for the specified widget.

Note
This function is available with widgets that derive from user interface descriptions created using uic.
See also
{Using a Designer UI File in Your Application}

Referenced by QAxSelect::QAxSelect().

◆ setVisible

void QWidget::setVisible ( bool  visible)
virtualslot

Reimplemented in QFileDialog, QWizard, QInputDialog, QMessageBox, QPrintDialog, QFontDialog, QColorDialog, QPrintPreviewWidget, QPageSetupDialog, QPrintPreviewDialog, QDialog, and QSizeGrip.

Definition at line 7991 of file qwidget.cpp.

Referenced by QPrintDialogPrivate::_q_collapseOrExpandDialog(), QMdiSubWindow::changeEvent(), QColumnViewPrivate::closeColumns(), QColumnViewPrivate::createColumn(), QCalendarView::QCalendarView(), QDesktopScreenWidget::QDesktopScreenWidget(), QRubberBand::QRubberBand(), QWizardPrivate::recreateLayout(), QMainWindowLayout::removeFromMacToolbar(), QAbstractScrollAreaPrivate::replaceScrollBar(), QDockAreaLayout::restoreDockWidget(), QDockAreaLayoutInfo::restoreState(), QToolBarAreaLayout::restoreState(), QDeclarativeView::setRootObject(), QStackedLayout::setStackingMode(), QSizeGrip::setVisible(), QDialog::setVisible(), QPrintPreviewWidget::setVisible(), QMenuBar::setVisible(), QMdiSubWindow::showShaded(), QETWidget::translateEmbedEvent(), QMenuPrivate::updateActionRects(), QDockWidgetPrivate::updateButtons(), and QMainWindowLayout::updateGapIndicator().

7992 {
7993  if (visible) { // show
7995  return;
7996 
7997  Q_D(QWidget);
7998 
7999  // Designer uses a trick to make grabWidget work without showing
8000  if (!isWindow() && parentWidget() && parentWidget()->isVisible()
8002  parentWidget()->window()->d_func()->createRecursively();
8003 
8004  //we have to at least create toplevels before applyX11SpecificCommandLineArguments
8005  //but not children of non-visible parents
8006  QWidget *pw = parentWidget();
8008  && (isWindow() || pw->testAttribute(Qt::WA_WState_Created))) {
8009  create();
8010  }
8011 
8012 #if defined(Q_WS_X11)
8013  if (windowType() == Qt::Window)
8015 #elif defined(Q_WS_QWS)
8016  if (windowType() == Qt::Window)
8017  QApplicationPrivate::applyQWSSpecificCommandLineArguments(this);
8018 #endif
8019 
8020  bool wasResized = testAttribute(Qt::WA_Resized);
8021  Qt::WindowStates initialWindowState = windowState();
8022 
8023  // polish if necessary
8024  ensurePolished();
8025 
8026  // remember that show was called explicitly
8028  // whether we need to inform the parent widget immediately
8029  bool needUpdateGeometry = !isWindow() && testAttribute(Qt::WA_WState_Hidden);
8030  // we are no longer hidden
8032 
8033  if (needUpdateGeometry)
8034  d->updateGeometry_helper(true);
8035 
8036 #ifdef QT3_SUPPORT
8037  QApplication::sendPostedEvents(this, QEvent::ChildInserted);
8038 #endif
8039  // activate our layout before we and our children become visible
8040  if (d->layout)
8041  d->layout->activate();
8042 
8043  if (!isWindow()) {
8045  while (parent && parent->isVisible() && parent->d_func()->layout && !parent->data->in_show) {
8046  parent->d_func()->layout->activate();
8047  if (parent->isWindow())
8048  break;
8049  parent = parent->parentWidget();
8050  }
8051  if (parent)
8052  parent->d_func()->setDirtyOpaqueRegion();
8053  }
8054 
8055  // adjust size if necessary
8056  if (!wasResized
8057  && (isWindow() || !parentWidget()->d_func()->layout)) {
8058  if (isWindow()) {
8059  adjustSize();
8060  if (windowState() != initialWindowState)
8061  setWindowState(initialWindowState);
8062  } else {
8063  adjustSize();
8064  }
8065  setAttribute(Qt::WA_Resized, false);
8066  }
8067 
8069 
8070  if (isWindow() || parentWidget()->isVisible()) {
8071  // remove posted quit events when showing a new window
8073 
8074  d->show_helper();
8075 
8076 #if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS) || defined(Q_WS_MAC) || defined(Q_WS_QPA)
8077  qApp->d_func()->sendSyntheticEnterLeave(this);
8078 #endif
8079  }
8080 
8081  QEvent showToParentEvent(QEvent::ShowToParent);
8082  QApplication::sendEvent(this, &showToParentEvent);
8083  } else { // hide
8085  return;
8086 #if defined(Q_WS_WIN)
8087  // reset WS_DISABLED style in a Blocked window
8090  {
8091  LONG dwStyle = GetWindowLong(winId(), GWL_STYLE);
8092  dwStyle &= ~WS_DISABLED;
8093  SetWindowLong(winId(), GWL_STYLE, dwStyle);
8094  }
8095 #endif
8098 
8099  Q_D(QWidget);
8100 
8101  // hw: The test on getOpaqueRegion() needs to be more intelligent
8102  // currently it doesn't work if the widget is hidden (the region will
8103  // be clipped). The real check should be testing the cached region
8104  // (and dirty flag) directly.
8105  if (!isWindow() && parentWidget()) // && !d->getOpaqueRegion().isEmpty())
8106  parentWidget()->d_func()->setDirtyOpaqueRegion();
8107 
8111  d->hide_helper();
8112 
8113  // invalidate layout similar to updateGeometry()
8114  if (!isWindow() && parentWidget()) {
8115  if (parentWidget()->d_func()->layout)
8116  parentWidget()->d_func()->layout->invalidate();
8117  else if (parentWidget()->isVisible())
8119  }
8120 
8121  QEvent hideToParentEvent(QEvent::HideToParent);
8122  QApplication::sendEvent(this, &hideToParentEvent);
8123  }
8124 }
double d
Definition: qnumeric_p.h:62
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
Qt::WindowStates windowState() const
Returns the current window state.
Definition: qwidget.cpp:3086
void setWindowState(Qt::WindowStates state)
Sets the window state to windowState.
void ensurePolished() const
Ensures that the widget has been polished by QStyle (i.e., has a proper font and palette).
Definition: qwidget.cpp:10024
bool isWindow() const
Returns true if the widget is an independent window, otherwise returns false.
Definition: qwidget.h:945
static void postEvent(QObject *receiver, QEvent *event)
Adds the event event, with the object receiver as the receiver of the event, to an event queue and re...
bool isVisible() const
Definition: qwidget.h:1005
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
bool activate()
Redoes the layout for parentWidget() if necessary.
Definition: qlayout.cpp:1249
void invalidate()
Reimplemented Function
Definition: qlayout.cpp:673
#define Q_D(Class)
Definition: qglobal.h:2482
bool visible
whether the widget is visible
Definition: qwidget.h:191
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
#define qApp
void adjustSize()
Adjusts the size of the widget to fit its contents.
Definition: qwidget.cpp:8488
QWidgetData * data
Definition: qwidget.h:815
static QWidget * hidden_focus_widget
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
static void sendPostedEvents()
void create(WId=0, bool initializeWindow=true, bool destroyOldWindow=true)
Creates a new widget window if window is 0, otherwise sets the widget&#39;s window to window...
Definition: qwidget.cpp:1454
static bool isBlockedByModal(QWidget *widget)
Returns true if widget is blocked by a modal window.
QObject * parent() const
Returns a pointer to the parent object.
Definition: qobject.h:273
void setAttribute(Qt::WidgetAttribute, bool on=true)
Sets the attribute attribute on this widget if on is true; otherwise clears the attribute.
Definition: qwidget.cpp:11087
static void applyX11SpecificCommandLineArguments(QWidget *main_widget)
QWidget * window() const
Returns the window for this widget, i.e.
Definition: qwidget.cpp:4492
QLayout * layout() const
Returns the layout manager that is installed on this widget, or 0 if no layout manager is installed...
Definition: qwidget.cpp:10073
Qt::WindowType windowType() const
Returns the window type of this widget.
Definition: qwidget.h:937
WId winId() const
Returns the window system identifier of the widget.
Definition: qwidget.cpp:2557
removePostedEvents
Removes all events of the given eventType that were posted using postEvent() for receiver.
The QEvent class is the base class of all event classes.
Definition: qcoreevent.h:56
uint in_show
Definition: qwidget.h:124

◆ setWhatsThis()

void QWidget::setWhatsThis ( const QString s)

Definition at line 11655 of file qwidget.cpp.

Referenced by QWhatsThis::QWhatsThis(), QToolButton::setDefaultAction(), and QListWidgetItem::whatsThis().

11656 {
11657  Q_D(QWidget);
11658  d->whatsThis = s;
11659 }
double d
Definition: qnumeric_p.h:62
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_D(Class)
Definition: qglobal.h:2482

◆ setWindowFilePath()

void QWidget::setWindowFilePath ( const QString filePath)

Definition at line 6449 of file qwidget.cpp.

6450 {
6451  if (filePath == windowFilePath())
6452  return;
6453 
6454  Q_D(QWidget);
6455 
6456  d->createTLExtra();
6457  d->extra->topextra->filePath = filePath;
6458  d->setWindowFilePath_helper(filePath);
6459 }
double d
Definition: qnumeric_p.h:62
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_D(Class)
Definition: qglobal.h:2482
QString windowFilePath() const

◆ setWindowFlags()

void QWidget::setWindowFlags ( Qt::WindowFlags  type)

Definition at line 10399 of file qwidget.cpp.

Referenced by QMdiAreaPrivate::appendChild(), QRubberBand::changeEvent(), QDialog::exec(), QMdiAreaPrivate::highlightNextSubWindow(), QDesktopScreenWidget::QDesktopScreenWidget(), QDialog::QDialog(), QmlJSDebugger::QmlToolBar::QmlToolBar(), qt_mac_updateToolBarButtonHint(), QWizard::QWizard(), QmlJSDebugger::AbstractViewInspector::setShowAppOnTop(), QColorDialog::setVisible(), and QMdiSubWindowPrivate::setWindowFlags().

10400 {
10401  if (data->window_flags == flags)
10402  return;
10403 
10404  Q_D(QWidget);
10405 
10406  if ((data->window_flags | flags) & Qt::Window) {
10407  // the old type was a window and/or the new type is a window
10408  QPoint oldPos = pos();
10409  bool visible = isVisible();
10410  setParent(parentWidget(), flags);
10411 
10412  // if both types are windows or neither of them are, we restore
10413  // the old position
10414  if (!((data->window_flags ^ flags) & Qt::Window)
10415  && (visible || testAttribute(Qt::WA_Moved))) {
10416  move(oldPos);
10417  }
10418  // for backward-compatibility we change Qt::WA_QuitOnClose attribute value only when the window was recreated.
10419  d->adjustQuitOnCloseAttribute();
10420  } else {
10421  data->window_flags = flags;
10422  }
10423 }
QPoint pos() const
double d
Definition: qnumeric_p.h:62
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
void setParent(QWidget *parent)
Sets the parent of the widget to parent, and resets the window flags.
Definition: qwidget.cpp:10479
bool isVisible() const
Definition: qwidget.h:1005
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_D(Class)
Definition: qglobal.h:2482
bool visible
whether the widget is visible
Definition: qwidget.h:191
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
Qt::WindowFlags window_flags
Definition: qwidget.h:119
QWidgetData * data
Definition: qwidget.h:815
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
void move(int x, int y)
This corresponds to move(QPoint(x, y)).
Definition: qwidget.h:1011

◆ setWindowIcon()

void QWidget::setWindowIcon ( const QIcon icon)

Definition at line 6362 of file qwidget.cpp.

Referenced by QMdi::ControlContainer::ControlContainer(), QWorkspaceChild::QWorkspaceChild(), QMdiSubWindow::setWidget(), update(), and QMdi::ControlContainer::updateWindowIcon().

6363 {
6364  Q_D(QWidget);
6365 
6367  d->createTLExtra();
6368 
6369  if (!d->extra->topextra->icon)
6370  d->extra->topextra->icon = new QIcon();
6371  *d->extra->topextra->icon = icon;
6372 
6373  delete d->extra->topextra->iconPixmap;
6374  d->extra->topextra->iconPixmap = 0;
6375 
6376  d->setWindowIcon_sys();
6377  d->setWindowIcon_helper();
6378 }
double d
Definition: qnumeric_p.h:62
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_D(Class)
Definition: qglobal.h:2482
bool isNull() const
Returns true if the icon is empty; otherwise returns false.
Definition: qicon.cpp:769
void setAttribute(Qt::WidgetAttribute, bool on=true)
Sets the attribute attribute on this widget if on is true; otherwise clears the attribute.
Definition: qwidget.cpp:11087
The QIcon class provides scalable icons in different modes and states.
Definition: qicon.h:60

◆ setWindowIconText()

void QWidget::setWindowIconText ( const QString iconText)

Definition at line 6299 of file qwidget.cpp.

6300 {
6301  if (QWidget::windowIconText() == iconText)
6302  return;
6303 
6304  Q_D(QWidget);
6305  d->topData()->iconText = iconText;
6306  d->setWindowIconText_helper(iconText);
6307 
6309  QApplication::sendEvent(this, &e);
6310 }
double d
Definition: qnumeric_p.h:62
QString windowIconText() const
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_D(Class)
Definition: qglobal.h:2482
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
The QEvent class is the base class of all event classes.
Definition: qcoreevent.h:56

◆ setWindowModality()

void QWidget::setWindowModality ( Qt::WindowModality  windowModality)

Definition at line 2991 of file qwidget.cpp.

Referenced by create(), QMessageBox::critical(), QDialog::open(), and QMessageBox::setWindowModality().

2992 {
2994  // setModal_sys() will be called by setAttribute()
2997 }
uint window_modality
Definition: qwidget.h:128
Qt::WindowModality windowModality() const
QWidgetData * data
Definition: qwidget.h:815
void setAttribute(Qt::WidgetAttribute, bool on=true)
Sets the attribute attribute on this widget if on is true; otherwise clears the attribute.
Definition: qwidget.cpp:11087

◆ setWindowModified

void QWidget::setWindowModified ( bool  mod)
slot

Definition at line 11559 of file qwidget.cpp.

Referenced by QMdiSubWindow::event(), QWorkspace::eventFilter(), QMdiSubWindow::eventFilter(), QWorkspaceChild::eventFilter(), QMdiSubWindowPrivate::removeButtonsFromMenuBar(), QMdiSubWindow::setWidget(), and QMdiSubWindowPrivate::showButtonsInMenuBar().

11560 {
11561  Q_D(QWidget);
11563 
11564 #ifndef Q_WS_MAC
11565  if (!windowTitle().contains(QLatin1String("[*]")) && mod)
11566  qWarning("QWidget::setWindowModified: The window title does not contain a '[*]' placeholder");
11567 #endif
11568  d->setWindowTitle_helper(windowTitle());
11569  d->setWindowIconText_helper(windowIconText());
11570 #ifdef Q_WS_MAC
11571  d->setWindowModified_sys(mod);
11572 #endif
11573 
11575  QApplication::sendEvent(this, &e);
11576 }
double d
Definition: qnumeric_p.h:62
QString windowIconText() const
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
#define Q_D(Class)
Definition: qglobal.h:2482
Q_CORE_EXPORT void qWarning(const char *,...)
QString windowTitle() const
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
void setAttribute(Qt::WidgetAttribute, bool on=true)
Sets the attribute attribute on this widget if on is true; otherwise clears the attribute.
Definition: qwidget.cpp:11087
The QEvent class is the base class of all event classes.
Definition: qcoreevent.h:56

◆ setWindowOpacity()

void QWidget::setWindowOpacity ( qreal  level)

Definition at line 11497 of file qwidget.cpp.

Referenced by QWindowsXPStyle::polish(), QMacStyle::polish(), QTipLabel::QTipLabel(), QAlphaWidget::render(), QAlphaWidget::run(), QWindowsXPStyle::unpolish(), QMacStyle::unpolish(), and QAlphaWidget::~QAlphaWidget().

11498 {
11499  Q_D(QWidget);
11500  if (!isWindow())
11501  return;
11502 
11503  opacity = qBound(qreal(0.0), opacity, qreal(1.0));
11504  QTLWExtra *extra = d->topData();
11505  extra->opacity = uint(opacity * 255);
11507 
11508 #ifndef Q_WS_QWS
11510  return;
11511 #endif
11512 
11513 #ifndef QT_NO_GRAPHICSVIEW
11514  if (QGraphicsProxyWidget *proxy = graphicsProxyWidget()) {
11515  // Avoid invalidating the cache if set.
11516  if (proxy->cacheMode() == QGraphicsItem::NoCache)
11517  proxy->update();
11518  else if (QGraphicsScene *scene = proxy->scene())
11519  scene->update(proxy->sceneBoundingRect());
11520  return;
11521  }
11522 #endif
11523 
11524  d->setWindowOpacity_sys(opacity);
11525 }
double d
Definition: qnumeric_p.h:62
The QGraphicsScene class provides a surface for managing a large number of 2D graphical items...
double qreal
Definition: qglobal.h:1193
bool isWindow() const
Returns true if the widget is an independent window, otherwise returns false.
Definition: qwidget.h:945
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
QGraphicsProxyWidget * graphicsProxyWidget() const
Returns the proxy widget for the corresponding embedded widget in a graphics view; otherwise returns ...
Definition: qwidget.cpp:12939
#define Q_D(Class)
Definition: qglobal.h:2482
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
unsigned int uint
Definition: qglobal.h:996
The QGraphicsProxyWidget class provides a proxy layer for embedding a QWidget in a QGraphicsScene...
Q_DECL_CONSTEXPR const T & qBound(const T &min, const T &val, const T &max)
Definition: qglobal.h:1219
uint opacity
Definition: qwidget_p.h:185
void setAttribute(Qt::WidgetAttribute, bool on=true)
Sets the attribute attribute on this widget if on is true; otherwise clears the attribute.
Definition: qwidget.cpp:11087

◆ setWindowRole()

void QWidget::setWindowRole ( const QString role)

Sets the window's role to role.

This only makes sense for windows on X11.

Definition at line 6493 of file qwidget.cpp.

6494 {
6495 #if defined(Q_WS_X11)
6496  Q_D(QWidget);
6497  d->topData()->role = role;
6498  d->setWindowRole();
6499 #else
6500  Q_UNUSED(role)
6501 #endif
6502 }
double d
Definition: qnumeric_p.h:62
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_D(Class)
Definition: qglobal.h:2482
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ setWindowState()

void QWidget::setWindowState ( Qt::WindowStates  windowState)

Sets the window state to windowState.

The window state is a OR'ed combination of Qt::WindowState: Qt::WindowMinimized, Qt::WindowMaximized, Qt::WindowFullScreen, and Qt::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 normal mode, use the following code:

w->setWindowState(w->windowState() ^ Qt::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() & ~Qt::WindowMinimized | Qt::WindowActive);

Calling this function will hide the widget. You must call show() to make the widget visible again.

Note
On some window systems Qt::WindowActive is not immediate, and may be ignored in certain cases.

When the window state changes, the widget receives a changeEvent() of type QEvent::WindowStateChange.

See also
Qt::WindowState windowState()

Definition at line 3740 of file qwidget_mac.mm.

Referenced by effectiveState(), QDialog::event(), QDialog::exec(), QApplicationPrivate::globalEventProcessor(), qstring_to_xtp(), qt_grab_cursor(), qt_tablet_cleanup_wce(), QtWndProc(), QDockAreaLayout::restoreDockWidget(), restoreGeometry(), QToolBarAreaLayout::restoreState(), QWorkspace::setActiveWindow(), QDialog::setVisible(), setVisible(), QDialog::showEvent(), showFullScreen(), showMaximized(), QWorkspaceChild::showMaximized(), showMinimized(), QWorkspaceChild::showMinimized(), showNormal(), and QWorkspaceChild::showNormal().

3741 {
3742  Q_D(QWidget);
3743  bool needShow = false;
3744  Qt::WindowStates oldstate = windowState();
3745  if (oldstate == newstate)
3746  return;
3747 
3748 #ifdef QT_MAC_USE_COCOA
3750 #endif
3751  bool needSendStateChange = true;
3752  if(isWindow()) {
3753  if((oldstate & Qt::WindowFullScreen) != (newstate & Qt::WindowFullScreen)) {
3754  if(newstate & Qt::WindowFullScreen) {
3755  if(QTLWExtra *tlextra = d->topData()) {
3756  if(tlextra->normalGeometry.width() < 0) {
3758  adjustSize();
3759  tlextra->normalGeometry = geometry();
3760  }
3761  tlextra->savedFlags = windowFlags();
3762  }
3763  needShow = isVisible();
3764  const QRect fullscreen(qApp->desktop()->screenGeometry(qApp->desktop()->screenNumber(this)));
3765  setParent(parentWidget(), Qt::Window | Qt::FramelessWindowHint | (windowFlags() & 0xffff0000)); //save
3766  setGeometry(fullscreen);
3767  if(!qApp->desktop()->screenNumber(this))
3769  } else {
3770  needShow = isVisible();
3771  if(!qApp->desktop()->screenNumber(this))
3773  setParent(parentWidget(), d->topData()->savedFlags);
3774  setGeometry(d->topData()->normalGeometry);
3775  d->topData()->normalGeometry.setRect(0, 0, -1, -1);
3776  }
3777  }
3778 
3779  d->createWinId();
3780 
3782  if((oldstate & Qt::WindowMinimized) != (newstate & Qt::WindowMinimized)) {
3783  if (newstate & Qt::WindowMinimized) {
3784 #ifndef QT_MAC_USE_COCOA
3785  CollapseWindow(window, true);
3786 #else
3787  [window miniaturize:window];
3788 #endif
3789  } else {
3790 #ifndef QT_MAC_USE_COCOA
3791  CollapseWindow(window, false);
3792 #else
3793  [window deminiaturize:window];
3794 #endif
3795  }
3796  needSendStateChange = oldstate == windowState(); // Collapse didn't change our flags.
3797  }
3798 
3799  if((newstate & Qt::WindowMaximized) && !((newstate & Qt::WindowFullScreen))) {
3800  if(QTLWExtra *tlextra = d->topData()) {
3801  if(tlextra->normalGeometry.width() < 0) {
3803  adjustSize();
3804  tlextra->normalGeometry = geometry();
3805  }
3806  }
3807  } else if(!(newstate & Qt::WindowFullScreen)) {
3808 // d->topData()->normalGeometry = QRect(0, 0, -1, -1);
3809  }
3810 
3811 #ifdef DEBUG_WINDOW_STATE
3812 #define WSTATE(x) qDebug("%s -- %s --> %s", #x, (oldstate & x) ? "true" : "false", (newstate & x) ? "true" : "false")
3813  WSTATE(Qt::WindowMinimized);
3814  WSTATE(Qt::WindowMaximized);
3815  WSTATE(Qt::WindowFullScreen);
3816 #undef WSTATE
3817 #endif
3818  if(!(newstate & (Qt::WindowMinimized|Qt::WindowFullScreen)) &&
3819  ((oldstate & Qt::WindowFullScreen) || (oldstate & Qt::WindowMinimized) ||
3820  (oldstate & Qt::WindowMaximized) != (newstate & Qt::WindowMaximized))) {
3821  if(newstate & Qt::WindowMaximized) {
3822  data->fstrut_dirty = true;
3823 #ifndef QT_MAC_USE_COCOA
3824  HIToolbarRef toolbarRef;
3825  if (GetWindowToolbar(window, &toolbarRef) == noErr && toolbarRef
3826  && !isVisible() && !IsWindowToolbarVisible(window)) {
3827  // HIToolbar, needs to be shown so that it's in the structure window
3828  // Typically this is part of a main window and will get shown
3829  // during the show, but it's will make the maximize all wrong.
3830  ShowHideWindowToolbar(window, true, false);
3831  d->updateFrameStrut(); // In theory the dirty would work, but it's optimized out if the window is not visible :(
3832  }
3833  Rect bounds;
3835  QRect avail = dsk->availableGeometry(dsk->screenNumber(this));
3836  SetRect(&bounds, avail.x(), avail.y(), avail.x() + avail.width(), avail.y() + avail.height());
3837  if(QWExtra *extra = d->extraData()) {
3838  if(bounds.right - bounds.left > extra->maxw)
3839  bounds.right = bounds.left + extra->maxw;
3840  if(bounds.bottom - bounds.top > extra->maxh)
3841  bounds.bottom = bounds.top + extra->maxh;
3842  }
3843  if(d->topData()) {
3844  QRect fs = d->frameStrut();
3845  bounds.left += fs.left();
3846  if(bounds.right < avail.x()+avail.width())
3847  bounds.right = qMin<short>((uint)avail.x()+avail.width(), bounds.right+fs.left());
3848  if(bounds.bottom < avail.y()+avail.height())
3849  bounds.bottom = qMin<short>((uint)avail.y()+avail.height(), bounds.bottom+fs.top());
3850  bounds.top += fs.top();
3851  bounds.right -= fs.right();
3852  bounds.bottom -= fs.bottom();
3853  }
3854  QRect orect(geometry().x(), geometry().y(), width(), height()),
3855  nrect(bounds.left, bounds.top, bounds.right - bounds.left,
3856  bounds.bottom - bounds.top);
3857  if(orect != nrect) { // the new rect differ from the old
3858  Point idealSize = { nrect.height(), nrect.width() };
3859  ZoomWindowIdeal(window, inZoomOut, &idealSize);
3860  }
3861 #else
3862  NSToolbar *toolbarRef = [window toolbar];
3863  if (toolbarRef && !isVisible() && ![toolbarRef isVisible]) {
3864  // HIToolbar, needs to be shown so that it's in the structure window
3865  // Typically this is part of a main window and will get shown
3866  // during the show, but it's will make the maximize all wrong.
3867  // ### Not sure this is right for NSToolbar...
3868  [toolbarRef setVisible:true];
3869 // ShowHideWindowToolbar(window, true, false);
3870  d->updateFrameStrut(); // In theory the dirty would work, but it's optimized out if the window is not visible :(
3871  }
3872  // Everything should be handled by Cocoa.
3874  [window zoom:window];
3875  } else {
3877  QRect avail = dsk->availableGeometry(dsk->screenNumber(this));
3878  setGeometry(avail);
3879  }
3880 
3881 #endif
3882  needSendStateChange = oldstate == windowState(); // Zoom didn't change flags.
3883  } else if(oldstate & Qt::WindowMaximized && !(oldstate & Qt::WindowFullScreen)) {
3884 #ifndef QT_MAC_USE_COCOA
3885  Point idealSize;
3886  ZoomWindowIdeal(window, inZoomIn, &idealSize);
3887 #else
3888  [window zoom:window];
3889 #endif
3890  if(QTLWExtra *tlextra = d->topData()) {
3891  setGeometry(tlextra->normalGeometry);
3892  tlextra->normalGeometry.setRect(0, 0, -1, -1);
3893  }
3894  }
3895  }
3896  }
3897 
3898  data->window_state = newstate;
3899 
3900  if(needShow)
3901  show();
3902 
3903  if(newstate & Qt::WindowActive)
3904  activateWindow();
3905 
3907  if (needSendStateChange) {
3908  QWindowStateChangeEvent e(oldstate);
3909  QApplication::sendEvent(this, &e);
3910  }
3911 }
double d
Definition: qnumeric_p.h:62
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
static void qt_mac_set_fullscreen_mode(bool b)
Definition: qwidget_mac.mm:406
int y() const
void setParent(QWidget *parent)
Sets the parent of the widget to parent, and resets the window flags.
Definition: qwidget.cpp:10479
Qt::WindowStates windowState() const
Returns the current window state.
Definition: qwidget.cpp:3086
bool isWindow() const
Returns true if the widget is an independent window, otherwise returns false.
Definition: qwidget.h:945
bool isVisible() const
Definition: qwidget.h:1005
uint window_state
Definition: qwidget.h:120
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
int left() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:240
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
friend OSWindowRef qt_mac_window_for(const QWidget *w)
Definition: qwidget_mac.mm:484
void setGeometry(int x, int y, int w, int h)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qwidget.h:1017
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
int bottom() const
Returns the y-coordinate of the rectangle&#39;s bottom edge.
Definition: qrect.h:249
#define Q_D(Class)
Definition: qglobal.h:2482
int height() const
NSToolbar * toolbar
WindowRef OSWindowRef
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
#define qApp
int width() const
void adjustSize()
Adjusts the size of the widget to fit its contents.
Definition: qwidget.cpp:8488
QWidgetData * data
Definition: qwidget.h:815
unsigned int uint
Definition: qglobal.h:996
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
void show()
Shows the widget and its child widgets.
virtual void setVisible(bool visible)
Definition: qwidget.cpp:7991
static QDesktopWidget * desktop()
Returns the desktop widget (also called the root window).
int top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:243
The QWindowStateChangeEvent class provides the window state before a window state change...
Definition: qevent.h:705
int right() const
Returns the x-coordinate of the rectangle&#39;s right edge.
Definition: qrect.h:246
int x() const
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
void activateWindow()
Sets the top-level widget containing this widget to be the active window.
QWidget * window() const
Returns the window for this widget, i.e.
Definition: qwidget.cpp:4492
int screenNumber(const QWidget *widget=0) const
uint fstrut_dirty
Definition: qwidget.h:126
const QRect availableGeometry(int screen=-1) const
Qt::WindowFlags windowFlags() const
Window flags are a combination of a type (e.
Definition: qwidget.h:939
const QRect & geometry() const
friend void qt_event_request_window_change(QWidget *widget)
static Qt::KeyboardModifiers oldstate
Definition: qdnd_qws.cpp:87

◆ setWindowSurface()

void QWidget::setWindowSurface ( QWindowSurface surface)

Sets the window surface to be the surface specified.

This function is under development and subject to change.

Since
4.2

The QWidget takes will ownership of the surface. widget itself is deleted.

Definition at line 12774 of file qwidget.cpp.

Referenced by PvrEglScreenSurfaceFunctions::createNativeWindow(), QRuntimeGraphicsSystem::createWindowSurface(), and QWindowSurface::QWindowSurface().

12775 {
12776  // ### createWinId() ??
12777 
12778 #ifndef Q_BACKINGSTORE_SUBSURFACES
12779  if (!isTopLevel())
12780  return;
12781 #endif
12782 
12783  Q_D(QWidget);
12784 
12785  QTLWExtra *topData = d->topData();
12786  if (topData->windowSurface == surface)
12787  return;
12788 
12789  QWindowSurface *oldSurface = topData->windowSurface;
12790  delete topData->windowSurface;
12791  topData->windowSurface = surface;
12792 
12793  QWidgetBackingStore *bs = d->maybeBackingStore();
12794  if (!bs)
12795  return;
12796 
12797  if (isTopLevel()) {
12798  if (bs->windowSurface != oldSurface && bs->windowSurface != surface)
12799  delete bs->windowSurface;
12800  bs->windowSurface = surface;
12801  }
12802 #ifdef Q_BACKINGSTORE_SUBSURFACES
12803  else {
12804  bs->subSurfaces.append(surface);
12805  }
12806  bs->subSurfaces.removeOne(oldSurface);
12807 #endif
12808 }
double d
Definition: qnumeric_p.h:62
QWindowSurface * windowSurface
QWindowSurface * windowSurface
Definition: qwidget_p.h:167
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_D(Class)
Definition: qglobal.h:2482
The QWindowSurface class provides the drawing area for top-level windows.
bool isTopLevel() const
Use isWindow() instead.
Definition: qwidget.h:942

◆ setWindowTitle

void QWidget::setWindowTitle ( const QString title)
slot

Definition at line 6312 of file qwidget.cpp.

Referenced by QAxClientSite::activateObject(), QMainWindow::addToolBar(), QMessageBox::critical(), QWorkspace::eventFilter(), QWorkspaceChild::eventFilter(), QColorDialog::getColor(), QInputDialog::getDouble(), QFontDialogPrivate::getFont(), QInputDialog::getInt(), QInputDialog::getText(), QWorkspaceChild::iconWidget(), QToolBar::isAreaAllowed(), parseGeometry(), QAbstractPageSetupDialog::QAbstractPageSetupDialog(), QAbstractPrintDialog::QAbstractPrintDialog(), QDockWidget::QDockWidget(), QmlJSDebugger::QmlToolBar::QmlToolBar(), QErrorMessage::qtHandler(), QToolBar::QToolBar(), QTornOffMenu::QTornOffMenu(), QWorkspaceChild::QWorkspaceChild(), QWorkspaceTitleBar::QWorkspaceTitleBar(), QMdi::ControlContainer::removeButtonsFromMenuBar(), QAccessibleMdiSubWindow::setText(), QMessageBox::setWindowTitle(), QScriptEngineDebugger::standardWindow(), and QCoreFuriCuri::timerEvent().

6313 {
6314  if (QWidget::windowTitle() == title && !title.isEmpty() && !title.isNull())
6315  return;
6316 
6317  Q_D(QWidget);
6318  d->topData()->caption = title;
6319  d->setWindowTitle_helper(title);
6320 
6322  QApplication::sendEvent(this, &e);
6323 }
double d
Definition: qnumeric_p.h:62
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_D(Class)
Definition: qglobal.h:2482
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
QString windowTitle() const
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
bool isNull() const
Returns true if this string is null; otherwise returns false.
Definition: qstring.h:505
The QEvent class is the base class of all event classes.
Definition: qcoreevent.h:56

◆ show

void QWidget::show ( )
slot

Shows the widget and its child widgets.

This function is equivalent to setVisible(true).

See also
raise(), showEvent(), hide(), setVisible(), showMinimized(), showMaximized(), showNormal(), isVisible()

Definition at line 639 of file qwidget_wince.cpp.

Referenced by QScriptDebuggerPrivate::_q_findInScript(), QCalendarWidgetPrivate::_q_yearClicked(), QCalendarWidgetPrivate::_q_yearEditingFinished(), QMessageBox::about(), QMessageBox::aboutQt(), QAxClientSite::activateObject(), QAxServerBase::ActiveXProc(), QMenuPrivate::QMacMenuPrivate::addAction(), QDialogButtonBoxPrivate::addButtonsToLayout(), QMainWindow::addDockWidget(), QAbstractScrollArea::addScrollBarWidget(), QMainWindowLayout::animationFinished(), QBalloonTip::balloon(), QSplitter::childEvent(), QEgl::createSurface(), QInputDialogPrivate::ensureLayout(), QMdiSubWindowPrivate::enterRubberBandMode(), QFocusFrame::eventFilter(), QMdiSubWindow::eventFilter(), QDialog::exec(), QProgressDialog::forceShow(), QStatusBar::hideOrShow(), QWorkspacePrivate::insertIcon(), QToolBox::insertItem(), QStatusBar::insertPermanentWidget(), QStatusBar::insertWidget(), QSplitterPrivate::insertWidget(), QSplitterPrivate::insertWidget_helper(), QDialogButtonBoxPrivate::layoutButtons(), QTabBarPrivate::layoutTabs(), QMenuPrivate::mouseEventTaken(), QDialog::open(), QAbstractItemViewPrivate::openEditor(), QAbstractItemView::openPersistentEditor(), QGLOverlayWidget::paintGL(), QMenu::popup(), qt_mac_unregister_widget(), QAxClientSite::qt_metacall(), qt_x11_recreateWidget(), QApplication::qwsProcessEvent(), QMdi::ControlContainer::removeButtonsFromMenuBar(), QAlphaWidget::render(), QMainWindowLayout::restoreState(), QAlphaWidget::run(), QRollEffect::run(), QWhatsThisPrivate::say(), QRollEffect::scroll(), QProgressDialog::setCancelButton(), QAbstractScrollArea::setCornerWidget(), QStackedLayout::setCurrentIndex(), QToolBarLayout::setGeometry(), QAbstractItemView::setIndexWidget(), QInputDialogPrivate::setInputWidget(), QProgressDialog::setLabel(), QMdiSubWindowPrivate::setMaximizeMode(), QMdiSubWindowPrivate::setNormalMode(), QCompleter::setPopup(), QTreeView::setRootIsDecorated(), QmlJSDebugger::AbstractViewInspector::setShowAppOnTop(), QTableView::setShowGrid(), QHeaderView::setSortIndicatorShown(), QTabWidget::setTabBar(), QTabBar::setTabButton(), QProgressDialog::setValue(), QCalendarWidget::setVerticalHeaderFormat(), QMdiAreaPrivate::setViewMode(), QGraphicsProxyWidgetPrivate::setWidget_helper(), QDockWidgetLayout::setWidgetForRole(), QWorkspaceChild::show(), QMdi::ControlContainer::showButtonsInMenuBar(), QWidgetPrivate::showChildren(), QmlApplicationViewer::showExpanded(), showFullScreen(), showMaximized(), QErrorMessage::showMessage(), showMinimized(), showNormal(), QCompleterPrivate::showPopup(), QComboBox::showPopup(), QMdiAreaPrivate::showRubberBandFor(), QToolTip::showText(), QWorkspacePrivate::showWindow(), QWizardPrivate::switchToPage(), QAbstractItemView::updateEditorGeometries(), QComboBoxPrivateContainer::updateScrollers(), QDockAreaLayoutInfo::updateSeparatorWidgets(), QDockAreaLayout::updateSeparatorWidgets(), and QSystemTrayIconSys::x11Event().

640 {
641  Qt::WindowFlags flags = windowFlags() & 0xff;
642  int threshold = qApp->autoMaximizeThreshold();
643  if ((threshold < 0) || (windowState() & Qt::WindowFullScreen) || (windowState() & Qt::WindowMaximized)) {
644  setVisible(true);
645  return;
646  }
647  int height = sizeHint().height();
648  int screenHeight = (qreal(threshold) / 100.0f * qApp->desktop()->screenGeometry(this).height());
649  bool maximize = height > screenHeight;
650  if (!maximize) {
651  // If we do not maximize yet we check the widget and its child widgets whether they are
652  //vertically expanding. If one of the widgets is expanding we maximize.
653  QList<QWidget *> list = findChildren<QWidget *>();
654  bool expandingChild = sizePolicy().verticalPolicy () == QSizePolicy::Expanding;
655  for (int i = 0; (i < list.size()) && !expandingChild; ++i) {
656  expandingChild = list.at(i)->sizePolicy().verticalPolicy () == QSizePolicy::Expanding;
657  }
658  maximize = expandingChild;
659  }
660  if ((minimumSizeHint().height() > qApp->desktop()->screenGeometry(this).height()) || (minimumSizeHint().width() > qApp->desktop()->screenGeometry(this).width()))
661  maximize = false;
662 
663  if ((flags == Qt::Window || flags == Qt::Dialog) && maximize) {
666  setVisible(true);
667  }
668  else {
669  setVisible(true);
670  }
671 }
double qreal
Definition: qglobal.h:1193
Qt::WindowStates windowState() const
Returns the current window state.
Definition: qwidget.cpp:3086
void setWindowState(Qt::WindowStates state)
Sets the window state to windowState.
virtual QSize minimumSizeHint() const
int height() const
virtual QSize sizeHint() const
QSizePolicy sizePolicy() const
int width() const
Returns the width.
Definition: qsize.h:126
#define qApp
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
virtual void setVisible(bool visible)
Definition: qwidget.cpp:7991
QSizePolicy sizePolicy
the default layout behavior of the widget
Definition: qwidget.h:171
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
Policy verticalPolicy() const
Definition: qsizepolicy.h:119
int height() const
Returns the height.
Definition: qsize.h:129
Qt::WindowFlags windowFlags() const
Window flags are a combination of a type (e.
Definition: qwidget.h:939

◆ showEvent()

void QWidget::showEvent ( QShowEvent event)
protectedvirtual

This event handler can be reimplemented in a subclass to receive widget show events which are passed in the event parameter.

Non-spontaneous show events are sent to widgets immediately before they are shown. The spontaneous show events of windows are delivered afterwards.

Note: 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. After receiving a spontaneous hide event, a widget is still considered visible in the sense of isVisible().

See also
visible, event(), QShowEvent

Reimplemented in QMessageBox, QTextEdit, QGraphicsView, QPlainTextEdit, QComboBoxPrivateContainer, QComboBox, QTabBar, QTabWidget, QWhatsThat, QMdiArea, QAbstractSpinBox, QAxHostWidget, QProgressDialog, QX11EmbedContainer, QMdiSubWindow, QDialog, QWorkspace, QToolBox, QPrintPropertiesDialog, QStatusBar, QRubberBand, QWSEmbedWidget, and QSizeGrip.

Definition at line 9842 of file qwidget.cpp.

Referenced by QComboBox::addItems(), event(), QRubberBand::resize(), setShown(), QWidgetPrivate::show_helper(), QSizeGrip::showEvent(), QToolBox::showEvent(), QWorkspace::showEvent(), QMdiSubWindow::showEvent(), QMdiArea::showEvent(), QComboBox::showEvent(), QGraphicsView::showEvent(), and QPlainTextEdit::toPlainText().

9843 {
9844 }

◆ showFullScreen

void QWidget::showFullScreen ( )
slot

Shows the widget in full-screen mode.

Calling this function only affects windows.

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 Qt::X11BypassWindowManagerHint 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.

X11 window managers that follow modern post-ICCCM specifications support full-screen mode properly.

See also
showNormal(), showMaximized(), show(), hide(), isVisible()

Definition at line 3185 of file qwidget.cpp.

Referenced by QmlApplicationViewer::showExpanded().

3186 {
3187 #ifdef Q_WS_MAC
3188  // If the unified toolbar is enabled, we have to disable it before going fullscreen.
3189  QMainWindow *mainWindow = qobject_cast<QMainWindow*>(this);
3190  if (mainWindow && mainWindow->unifiedTitleAndToolBarOnMac()) {
3191  mainWindow->setUnifiedTitleAndToolBarOnMac(false);
3192  QMainWindowLayout *mainLayout = qobject_cast<QMainWindowLayout*>(mainWindow->layout());
3193  mainLayout->activateUnifiedToolbarAfterFullScreen = true;
3194  }
3195 #endif // Q_WS_MAC
3196  ensurePolished();
3197 #ifdef QT3_SUPPORT
3198  if (parent())
3199  QApplication::sendPostedEvents(parent(), QEvent::ChildInserted);
3200 #endif
3201 
3204  show();
3205  activateWindow();
3206 }
Qt::WindowStates windowState() const
Returns the current window state.
Definition: qwidget.cpp:3086
void setWindowState(Qt::WindowStates state)
Sets the window state to windowState.
void ensurePolished() const
Ensures that the widget has been polished by QStyle (i.e., has a proper font and palette).
Definition: qwidget.cpp:10024
T * qobject_cast(QObject *object)
Definition: qobject.h:375
bool activateUnifiedToolbarAfterFullScreen
static void sendPostedEvents()
void show()
Shows the widget and its child widgets.
bool unifiedTitleAndToolBarOnMac
whether the window uses the unified title and toolbar look on Mac OS X
Definition: qmainwindow.h:83
QObject * parent() const
Returns a pointer to the parent object.
Definition: qobject.h:273
The QMainWindow class provides a main application window.
Definition: qmainwindow.h:63
void activateWindow()
Sets the top-level widget containing this widget to be the active window.
QLayout * layout() const
Returns the layout manager that is installed on this widget, or 0 if no layout manager is installed...
Definition: qwidget.cpp:10073
void setUnifiedTitleAndToolBarOnMac(bool set)

◆ showMaximized

void QWidget::showMaximized ( )
slot

Shows the widget maximized.

Calling this function only affects windows.

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(), isVisible()

Definition at line 3218 of file qwidget.cpp.

Referenced by QWorkspace::addWindow(), QMdiAreaPrivate::emitWindowActivated(), QMdiSubWindow::event(), QMdiSubWindow::eventFilter(), main(), QMdiSubWindow::mouseDoubleClickEvent(), QApplication::qwsProcessEvent(), QApplication::qwsSetCustomColors(), QDecoration::regionClicked(), QDecoration::regionDoubleClicked(), QMdiAreaPrivate::setViewMode(), and QmlApplicationViewer::showExpanded().

3219 {
3220  ensurePolished();
3221 #ifdef QT3_SUPPORT
3222  if (parent())
3223  QApplication::sendPostedEvents(parent(), QEvent::ChildInserted);
3224 #endif
3225 
3228 #ifdef Q_WS_MAC
3229  // If the unified toolbar was enabled before going fullscreen, we have to enable it back.
3230  QMainWindow *mainWindow = qobject_cast<QMainWindow*>(this);
3231  if (mainWindow)
3232  {
3233  QMainWindowLayout *mainLayout = qobject_cast<QMainWindowLayout*>(mainWindow->layout());
3234  if (mainLayout->activateUnifiedToolbarAfterFullScreen) {
3235  mainWindow->setUnifiedTitleAndToolBarOnMac(true);
3236  mainLayout->activateUnifiedToolbarAfterFullScreen = false;
3237  }
3238  }
3239 #endif // Q_WS_MAC
3240  show();
3241 }
Qt::WindowStates windowState() const
Returns the current window state.
Definition: qwidget.cpp:3086
void setWindowState(Qt::WindowStates state)
Sets the window state to windowState.
void ensurePolished() const
Ensures that the widget has been polished by QStyle (i.e., has a proper font and palette).
Definition: qwidget.cpp:10024
T * qobject_cast(QObject *object)
Definition: qobject.h:375
bool activateUnifiedToolbarAfterFullScreen
static void sendPostedEvents()
void show()
Shows the widget and its child widgets.
QObject * parent() const
Returns a pointer to the parent object.
Definition: qobject.h:273
The QMainWindow class provides a main application window.
Definition: qmainwindow.h:63
QLayout * layout() const
Returns the layout manager that is installed on this widget, or 0 if no layout manager is installed...
Definition: qwidget.cpp:10073
void setUnifiedTitleAndToolBarOnMac(bool set)

◆ showMinimized

void QWidget::showMinimized ( )
slot

Shows the widget minimized, as an icon.

Calling this function only affects windows.

See also
showNormal(), showMaximized(), show(), hide(), isVisible(), isMinimized()

Definition at line 3038 of file qwidget.cpp.

Referenced by QWorkspace::addWindow(), QMdiSubWindow::event(), QMdiSubWindow::eventFilter(), QtWndProc(), and QApplication::qwsProcessEvent().

3039 {
3040  bool isMin = isMinimized();
3041  if (isMin && isVisible())
3042  return;
3043 
3044  ensurePolished();
3045 #ifdef QT3_SUPPORT
3046  if (parent())
3047  QApplication::sendPostedEvents(parent(), QEvent::ChildInserted);
3048 #endif
3049 
3050  if (!isMin)
3052  show();
3053 }
Qt::WindowStates windowState() const
Returns the current window state.
Definition: qwidget.cpp:3086
void setWindowState(Qt::WindowStates state)
Sets the window state to windowState.
void ensurePolished() const
Ensures that the widget has been polished by QStyle (i.e., has a proper font and palette).
Definition: qwidget.cpp:10024
bool isVisible() const
Definition: qwidget.h:1005
static void sendPostedEvents()
void show()
Shows the widget and its child widgets.
QObject * parent() const
Returns a pointer to the parent object.
Definition: qobject.h:273
bool isMinimized() const
Definition: qwidget.cpp:3027

◆ showNormal

void QWidget::showNormal ( )
slot

Restores the widget after it has been maximized or minimized.

Calling this function only affects windows.

See also
setWindowState(), showMinimized(), showMaximized(), show(), hide(), isVisible()

Definition at line 3250 of file qwidget.cpp.

Referenced by QMdiAreaPrivate::_q_deactivateAllWindows(), QMdiSubWindow::event(), QMdiSubWindow::eventFilter(), QMdiSubWindow::mouseDoubleClickEvent(), QApplication::qwsProcessEvent(), QMdiAreaPrivate::rearrange(), QDecoration::regionClicked(), QDecoration::regionDoubleClicked(), and QMdiAreaPrivate::setViewMode().

3251 {
3252  ensurePolished();
3253 #ifdef QT3_SUPPORT
3254  if (parent())
3255  QApplication::sendPostedEvents(parent(), QEvent::ChildInserted);
3256 #endif
3257 
3261 #ifdef Q_WS_MAC
3262  // If the unified toolbar was enabled before going fullscreen, we have to enable it back.
3263  QMainWindow *mainWindow = qobject_cast<QMainWindow*>(this);
3264  if (mainWindow)
3265  {
3266  QMainWindowLayout *mainLayout = qobject_cast<QMainWindowLayout*>(mainWindow->layout());
3267  if (mainLayout->activateUnifiedToolbarAfterFullScreen) {
3268  mainWindow->setUnifiedTitleAndToolBarOnMac(true);
3269  mainLayout->activateUnifiedToolbarAfterFullScreen = false;
3270  }
3271  }
3272 #endif // Q_WS_MAC
3273  show();
3274 }
Qt::WindowStates windowState() const
Returns the current window state.
Definition: qwidget.cpp:3086
void setWindowState(Qt::WindowStates state)
Sets the window state to windowState.
void ensurePolished() const
Ensures that the widget has been polished by QStyle (i.e., has a proper font and palette).
Definition: qwidget.cpp:10024
T * qobject_cast(QObject *object)
Definition: qobject.h:375
bool activateUnifiedToolbarAfterFullScreen
static void sendPostedEvents()
void show()
Shows the widget and its child widgets.
QObject * parent() const
Returns a pointer to the parent object.
Definition: qobject.h:273
The QMainWindow class provides a main application window.
Definition: qmainwindow.h:63
QLayout * layout() const
Returns the layout manager that is installed on this widget, or 0 if no layout manager is installed...
Definition: qwidget.cpp:10073
void setUnifiedTitleAndToolBarOnMac(bool set)

◆ size()

QSize QWidget::size ( ) const

Referenced by QPageSetupWidget::_q_paperSizeChanged(), QFontDialogPrivate::_q_sizeChanged(), QFontDialogPrivate::_q_sizeHighlighted(), QMessageBox::about(), QX11EmbedContainerPrivate::acceptClient(), QAxClientSite::activateObject(), QToolBarLayout::checkUsePopupMenu(), QSystemTrayIconSys::createIcon(), QHeaderViewPrivate::createSectionSpan(), QSplitterPrivate::doResize(), QVistaHelper::drawTitleBar(), QMdiSubWindow::event(), QAxHostWidget::event(), QMainWindowTabBar::event(), QWorkspaceChild::eventFilter(), QToolBarLayout::expandedSize(), QPixmap::fill(), fixToolBarOrientation(), QTabWidget::heightForWidth(), QAccessibleDisplay::imagePosition(), QFontDialogPrivate::init(), QTreeViewPrivate::itemDecorationRect(), QAbstractScrollArea::maximumViewportSize(), QGroupBox::minimumSizeHint(), QProgressBar::minimumSizeHint(), QMdiArea::minimumSizeHint(), QAxHostWidget::minimumSizeHint(), QTabBarPrivate::minimumTabSizeHint(), QHeaderView::moveSection(), QDockWidgetTitleButton::paintEvent(), QAxHostWidget::paintEvent(), QTabWidget::paintEvent(), QListView::paintEvent(), QTabBar::paintEvent(), QGraphicsView::paintEvent(), QMdiAreaPrivate::place(), QMenu::popup(), QtWndProc(), QWizardPrivate::QWizardPrivate(), QWidgetPrivate::render_helper(), QWSEmbedWidget::resizeEvent(), QAxWidget::resizeEvent(), QMdiArea::resizeEvent(), restoreGeometry(), QDeclarativeViewPrivate::rootObjectSize(), QDesktopWidget::screenNumber(), scroll(), QColumnView::scrollTo(), QHeaderView::sectionSizeFromContents(), QHeaderView::sectionSizeHint(), QWizardPrivate::setButtonLayout(), QDateTimeEdit::setCurrentSection(), QHeaderViewPrivate::setDefaultSectionSize(), QDockWidget::setFloating(), setGeometry(), QHeaderViewPrivate::setHeaderSectionResizeMode(), QAbstractButton::setIconSize(), QTabBar::setIconSize(), QComboBox::setIconSize(), QAbstractItemView::setIconSize(), QHeaderView::setMinimumSectionSize(), QHeaderView::setOffsetToLastSection(), QDeclarativeView::setRootObject(), QHeaderView::setSectionHidden(), QWizardHeader::setup(), QPageSetupWidget::setupPrinter(), QWSEmbedWidget::showEvent(), QMdiSubWindow::showEvent(), QMdiArea::showEvent(), QDialog::showExtension(), QWorkspaceChild::showShaded(), QScrollBar::sizeHint(), QCommandLinkButton::sizeHint(), QVistaBackButton::sizeHint(), QMdiSubWindow::sizeHint(), QWorkspace::sizeHint(), QProgressBar::sizeHint(), QMDIControl::sizeHint(), QProgressDialog::sizeHint(), QDeclarativeView::sizeHint(), QMdiArea::sizeHint(), QDockWidgetTitleButton::sizeHint(), QGraphicsView::sizeHint(), QTabWidget::sizeHint(), QWizard::sizeHint(), QMdi::ControllerWidget::sizeHint(), QMessageBoxPrivate::updateSize(), and QFontDialogPrivate::updateSizes().

◆ sizeHint()

virtual QSize QWidget::sizeHint ( ) const
virtual

◆ sizeIncrement()

QSize QWidget::sizeIncrement ( ) const

Referenced by setDisabled().

◆ sizePolicy()

QSizePolicy QWidget::sizePolicy ( ) const

◆ stackUnder()

void QWidget::stackUnder ( QWidget w)

Places the widget under w in the parent widget's stack.

To make this work, the widget itself and w must be siblings.

See also
raise(), lower()

Definition at line 11972 of file qwidget.cpp.

Referenced by QFocusFrame::eventFilter(), QMdiAreaPrivate::internalRaise(), and QWorkspaceChild::internalRaise().

11973 {
11974  Q_D(QWidget);
11975  QWidget *p = parentWidget();
11976  if (!w || isWindow() || p != w->parentWidget() || this == w)
11977  return;
11978  if (p) {
11979  int from = p->d_func()->children.indexOf(this);
11980  int to = p->d_func()->children.indexOf(w);
11981  Q_ASSERT(from >= 0);
11982  Q_ASSERT(to >= 0);
11983  if (from < to)
11984  --to;
11985  // Do nothing if the widget is already in correct stacking order _and_ created.
11986  if (from != to)
11987  p->d_func()->children.move(from, to);
11989  create();
11990  else if (from == to)
11991  return;
11992  }
11994  d->stackUnder_sys(w);
11995 
11997  QApplication::sendEvent(this, &e);
11998 }
double d
Definition: qnumeric_p.h:62
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
bool isWindow() const
Returns true if the widget is an independent window, otherwise returns false.
Definition: qwidget.h:945
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define Q_D(Class)
Definition: qglobal.h:2482
void move(int from, int to)
Moves the item at index position from to index position to.
Definition: qlist.h:628
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
void create(WId=0, bool initializeWindow=true, bool destroyOldWindow=true)
Creates a new widget window if window is 0, otherwise sets the widget&#39;s window to window...
Definition: qwidget.cpp:1454
int indexOf(const T &t, int from=0) const
Returns the index position of the first occurrence of value in the list, searching forward from index...
Definition: qlist.h:847
const QObjectList & children() const
Returns a list of child objects.
Definition: qobject.h:197
The QEvent class is the base class of all event classes.
Definition: qcoreevent.h:56

◆ statusTip()

QString QWidget::statusTip ( ) const

◆ style()

QStyle * QWidget::style ( ) const
See also
QWidget::setStyle(), QApplication::setStyle(), QApplication::style()

Definition at line 2742 of file qwidget.cpp.

Referenced by QFontDialogPrivate::_q_styleHighlighted(), QFontDialogPrivate::_q_updateSample(), QDialog::adjustPosition(), QWorkspaceChild::adjustToFullscreen(), QWorkspaceChild::baseSize(), QStylePainter::begin(), QMenuBarPrivate::calcActionRects(), QWorkspace::changeEvent(), QToolButton::changeEvent(), QMenuBar::changeEvent(), QAbstractButton::changeEvent(), QAbstractSpinBox::changeEvent(), QDialogButtonBox::changeEvent(), QMenu::changeEvent(), QTabBar::changeEvent(), QLineEdit::changeEvent(), QComboBoxPrivateContainer::changeEvent(), QComboBox::changeEvent(), QMessageBox::changeEvent(), QWorkspaceChild::changeEvent(), QItemDelegate::check(), QScrollBar::contextMenuEvent(), QWorkspaceTitleBar::contextMenuEvent(), QDefaultItemEditorFactory::createEditor(), QMenuBar::defaultAction(), QItemDelegate::doLayout(), QTreeView::drawBranches(), QItemDelegate::drawCheck(), QCommonStyle::drawControl(), QItemDelegate::drawDisplay(), QItemDelegate::drawFocus(), QFrame::drawFrame(), QTreeView::drawRow(), QStyledItemDelegate::editorEvent(), QWizardPrivate::ensureButton(), QGroupBox::event(), QMDIControl::event(), QAbstractScrollArea::event(), QMdiSubWindow::event(), QToolBar::event(), QMenu::event(), QWizard::event(), QLineEdit::event(), event(), QFocusFrame::eventFilter(), QWindowsStyle::eventFilter(), QMenuBar::eventFilter(), QToolBarLayout::expandedSize(), QLineEdit::focusInEvent(), QTextControl::getPaintContext(), QFormLayoutPrivate::getStyle(), QMdi::ControllerWidget::getSubControl(), QMenuBar::heightForWidth(), QTabWidget::heightForWidth(), QMenuPrivate::hideMenu(), QComboBox::hidePopup(), QRadioButton::hitButton(), QCheckBox::hitButton(), QWorkspaceChild::iconWidget(), QWidgetPrivate::inheritStyle(), QTabBarPrivate::initStyleBaseOption(), QToolButton::initStyleOption(), QToolBar::initStyleOption(), QLineEdit::initStyleOption(), QTabBar::insertTab(), QMenu::internalDelayedPopup(), QMenuBar::keyPressEvent(), QAbstractSpinBox::keyPressEvent(), QMenu::keyPressEvent(), QAbstractItemView::keyPressEvent(), QToolBarLayout::layoutActions(), QWizardPrivate::layoutInfoForCurrentPage(), QGroupBox::minimumSizeHint(), QToolBoxButton::minimumSizeHint(), QMdiSubWindow::minimumSizeHint(), QAbstractScrollArea::minimumSizeHint(), QSlider::minimumSizeHint(), QMdiArea::minimumSizeHint(), QMenuBar::minimumSizeHint(), QCalendarWidget::minimumSizeHint(), QAbstractSpinBox::minimumSizeHint(), QLineEdit::minimumSizeHint(), QTabWidget::minimumSizeHint(), QDockWidgetLayout::minimumTitleWidth(), QTreeView::mouseDoubleClickEvent(), QWorkspaceTitleBar::mouseDoubleClickEvent(), QAbstractItemView::mouseDoubleClickEvent(), QCalendarView::mouseDoubleClickEvent(), QScrollBar::mouseMoveEvent(), QMDIControl::mouseMoveEvent(), QGroupBox::mouseMoveEvent(), QMdiSubWindow::mouseMoveEvent(), QMenu::mouseMoveEvent(), QWorkspaceTitleBar::mouseMoveEvent(), QScrollBar::mousePressEvent(), QMDIControl::mousePressEvent(), QGroupBox::mousePressEvent(), QSlider::mousePressEvent(), QToolButton::mousePressEvent(), QMenuBar::mousePressEvent(), QCalendarPopup::mousePressEvent(), QTabBar::mousePressEvent(), QTreeView::mousePressEvent(), QComboBoxPrivateContainer::mousePressEvent(), QComboBox::mousePressEvent(), QWorkspaceTitleBar::mousePressEvent(), QMDIControl::mouseReleaseEvent(), QGroupBox::mouseReleaseEvent(), QSlider::mouseReleaseEvent(), QTabBar::mouseReleaseEvent(), QTreeView::mouseReleaseEvent(), QWorkspaceTitleBar::mouseReleaseEvent(), QAbstractItemView::mouseReleaseEvent(), QCalendarView::mouseReleaseEvent(), QTreeView::moveCursor(), QStyledItemDelegate::paint(), QColumnViewDelegate::paint(), QScriptDebuggerLocalsItemDelegate::paint(), QWellArray::paintCell(), QSizeGrip::paintEvent(), QFocusFrame::paintEvent(), QScrollBar::paintEvent(), QCommandLinkButton::paintEvent(), QToolBarSeparator::paintEvent(), QColumnViewGrip::paintEvent(), QToolBoxButton::paintEvent(), QMDIControl::paintEvent(), QStatusBar::paintEvent(), QSlider::paintEvent(), QComboBoxListView::paintEvent(), QDockWidgetTitleButton::paintEvent(), QMdiSubWindow::paintEvent(), QMenuBar::paintEvent(), QLabel::paintEvent(), QToolBar::paintEvent(), QTableView::paintEvent(), QListView::paintEvent(), QSplitterHandle::paintEvent(), QMenu::paintEvent(), QComboBoxPrivateScroller::paintEvent(), QTabBar::paintEvent(), QHeaderView::paintEvent(), QLineEdit::paintEvent(), CloseButton::paintEvent(), QGraphicsView::paintEvent(), QWorkspaceTitleBar::paintEvent(), QMdi::ControllerWidget::paintEvent(), QWorkspaceChild::paintEvent(), QHeaderView::paintSection(), paintSep(), QTipLabel::placeTip(), QMenu::popup(), previousInFocusChain(), QBalloonTip::QBalloonTip(), QComboBoxPrivateContainer::QComboBoxPrivateContainer(), QDockAreaLayout::QDockAreaLayout(), QFocusFrame::QFocusFrame(), QMainWindowLayout::QMainWindowLayout(), QMdiSubWindow::QMdiSubWindow(), QMenuBarExtension::QMenuBarExtension(), QRenderRule::QRenderRule(), qSmartSpacing(), qt_mac_buttonIsRenderedFlat(), qt_setWindowTitle_helperHelper(), QTipLabel::QTipLabel(), QWizardPrivate::QWizardPrivate(), QWorkspaceChild::QWorkspaceChild(), QWorkspaceTitleBar::QWorkspaceTitleBar(), QMdi::SimpleCascader::rearrange(), QAccessibleAbstractSpinBox::rect(), QAccessibleToolButton::rect(), QAccessibleDoubleSpinBox::rect(), QAccessibleScrollBar::rect(), QAccessibleSlider::rect(), QAccessibleComboBox::rect(), QGraphicsProxyWidgetPrivate::removeSubFocusHelper(), resetInputContext(), QTipLabel::resizeEvent(), QWorkspaceChild::resizeEvent(), QGraphicsViewPrivate::rubberBandRegion(), QHeaderView::sectionSizeFromContents(), setAttribute(), QTabBar::setCurrentIndex(), QHeaderView::setDefaultSectionSize(), QComboBox::setEditable(), setFocus(), QApplicationPrivate::setFocusWidget(), setFont(), QToolBarLayout::setGeometry(), QDockWidgetLayout::setGeometry(), QTableView::setGridStyle(), QMainWindow::setIconSize(), QToolBar::setIconSize(), QMessageBox::setInformativeText(), QComboBoxPrivateContainer::setItemView(), QComboBox::setMinimumContentsLength(), QToolBarExtension::setOrientation(), QLineEdit::setSelection(), QMenu::setSeparatorsCollapsible(), QSplitter::setSizes(), QApplication::setStyle(), QTabBar::setTabsClosable(), QToolButton::setToolButtonStyle(), QBoxLayoutPrivate::setupGeom(), QTabWidget::setUpLayout(), QGridLayoutPrivate::setupSpacings(), QFormLayoutPrivate::setupVerticalLayoutData(), QFocusFrame::setWidget(), QGraphicsProxyWidgetPrivate::setWidget_helper(), QMessageBox::setWindowModality(), QWizard::setWizardStyle(), QMdiSubWindow::showEvent(), QComboBox::showPopup(), QWorkspaceChild::showShaded(), showToolTip(), QDockWidgetLayout::sizeFromContent(), QSizeGrip::sizeHint(), QRadioButton::sizeHint(), QScrollBar::sizeHint(), QCheckBox::sizeHint(), QToolBarExtension::sizeHint(), QPushButton::sizeHint(), QStyledItemDelegate::sizeHint(), QToolBarSeparator::sizeHint(), QToolBoxButton::sizeHint(), QToolButton::sizeHint(), QSlider::sizeHint(), QProgressBar::sizeHint(), QMDIControl::sizeHint(), QProgressDialog::sizeHint(), QMenuBarExtension::sizeHint(), QMenuBar::sizeHint(), QDockWidgetTitleButton::sizeHint(), QAbstractSpinBox::sizeHint(), QTabWidget::sizeHint(), QLineEdit::sizeHint(), QMenu::sizeHint(), DetailButton::sizeHint(), QComboBoxPrivateScroller::sizeHint(), QDateTimeEdit::sizeHint(), QSplitterHandle::sizeHint(), CloseButton::sizeHint(), QWorkspaceTitleBar::sizeHint(), QMdi::ControllerWidget::sizeHint(), QMessageBoxPrivate::standardIcon(), QAccessibleMenuItem::state(), QDockAreaLayout::styleChangedEvent(), QCommonStyle::subElementRect(), QTabBar::tabSizeHint(), QDockWidgetLayout::titleHeight(), QMenuPrivate::updateActionRects(), QStyledItemDelegate::updateEditorGeometry(), QToolBarLayout::updateGeomArray(), QToolBarLayout::updateMarginAndSpacing(), QWorkspaceChild::updateMask(), QExpandingLineEdit::updateMinimumWidth(), QComboBoxPrivateContainer::updateScrollers(), QFormLayoutPrivate::updateSizes(), QFontDialogPrivate::updateStyles(), QComboBoxPrivateContainer::updateTopBottomMargin(), updateWidgets(), QMdi::ControlLabel::updateWindowIcon(), QListView::viewOptions(), QAbstractItemView::viewOptions(), and QX11Data::xdndMimeDataForAtom().

2743 {
2744  Q_D(const QWidget);
2745 
2746  if (d->extra && d->extra->style)
2747  return d->extra->style;
2748  return QApplication::style();
2749 }
double d
Definition: qnumeric_p.h:62
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
static QStyle * style()
Returns the application&#39;s style object.
#define Q_D(Class)
Definition: qglobal.h:2482

◆ styleChange()

void QWidget::styleChange ( QStyle style)
protectedvirtual
Warning
This function is not part of the public interface.

Definition at line 12000 of file qwidget.cpp.

Referenced by QApplication::setStyle(), and QWizard::setWizardStyle().

12000 { }

◆ styleSheet()

QString QWidget::styleSheet ( ) const

Referenced by effectiveWinId(), and setStyleSheet().

◆ tabletEvent()

void QWidget::tabletEvent ( QTabletEvent event)
protectedvirtual

This event handler, for event event, can be reimplemented in a subclass to receive tablet events for the widget.

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(), QTabletEvent

Definition at line 9347 of file qwidget.cpp.

Referenced by event(), and setShown().

9348 {
9349  event->ignore();
9350 }

◆ takeLayout()

QLayout * QWidget::takeLayout ( )
private

Remove the layout from the widget.

Since
4.5

Definition at line 10153 of file qwidget.cpp.

Referenced by focusPreviousChild(), and setLayout().

10154 {
10155  Q_D(QWidget);
10156  QLayout *l = layout();
10157  if (!l)
10158  return 0;
10159  d->layout = 0;
10160  l->setParent(0);
10161  return l;
10162 }
double d
Definition: qnumeric_p.h:62
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_D(Class)
Definition: qglobal.h:2482
void setParent(QObject *)
Makes the object a child of parent.
Definition: qobject.cpp:1950
The QLayout class is the base class of geometry managers.
Definition: qlayout.h:90
QFactoryLoader * l
QLayout * layout() const
Returns the layout manager that is installed on this widget, or 0 if no layout manager is installed...
Definition: qwidget.cpp:10073

◆ testAttribute()

bool QWidget::testAttribute ( Qt::WidgetAttribute  attribute) const
inline

Returns true if attribute attribute is set on this widget; otherwise returns false.

See also
setAttribute()

Definition at line 1041 of file qwidget.h.

Referenced by QGroupBoxPrivate::_q_setChildrenEnabled(), QWizardPrivate::_q_updateButtonStates(), acceptsDrop(), QLayout::addChildWidget(), QWidgetBackingStore::addStaticWidget(), QMdiArea::addSubWindow(), QWorkspace::addWindow(), QMdiAreaPrivate::appendChild(), QApplicationPrivate::applyX11SpecificCommandLineArguments(), QPainterPrivate::attachPainterPrivate(), QCoreGraphicsPaintEngine::begin(), QX11PaintEngine::begin(), QPainter::begin(), QDirectFBWindowSurface::beginPaint(), buildSpec(), QWidgetPrivate::childAtRecursiveHelper(), QGroupBox::childEvent(), QSplitter::childEvent(), clipboardData(), QWidgetPrivate::close_helper(), QMdiSubWindow::closeEvent(), QWinInputContext::composition(), QDialog::contextMenuEvent(), create(), QXIMInputContext::create_xim(), QWidgetPrivate::createRecursively(), QEgl::createSurface(), QVGGraphicsSystem::createWindowSurface(), QGLGraphicsSystem::createWindowSurface(), QWidgetPrivate::createWinId(), destroy(), discardSyncRequest(), QApplicationPrivate::dispatchEnterLeave(), do_size_hints(), QWindowsXPStylePrivate::drawBackground(), QWindowsVistaStyle::drawComplexControl(), QWindowsXPStyle::drawComplexControl(), QGtkStyle::drawComplexControl(), QMacStyle::drawComplexControl(), QCommonStyle::drawControl(), QWindowsCEStyle::drawControl(), QMacStyle::drawControl(), QGtkStyle::drawPrimitive(), QOleDropTarget::Drop(), effectiveWinId(), QWinInputContext::enable(), QWinInputContext::endComposition(), QGraphicsProxyWidget::event(), QDialog::event(), QMdiSubWindow::event(), QMacStyle::event(), QMainWindow::event(), QApplication::event(), event(), QSizeGrip::eventFilter(), QWhatsThisPrivate::eventFilter(), QDialog::exec(), find_child(), QX11Data::findClientWindow(), QRasterWindowSurface::flush(), QWidgetBackingStore::flushPaint(), QMacStyle::focusRectPolicy(), QApplication::font(), QFbScreen::generateRects(), QClipboardWatcher::getDataInFormat(), QSplitterLayoutStruct::getWidgetSize(), QMacInputContext::globalEventProcessor(), QApplicationPrivate::globalEventProcessor(), QPixmap::grabWidget(), QWidgetPrivate::hideChildren(), QStatusBar::hideOrShow(), QGLWindowSurface::hijackWindow(), QStyleOption::init(), QMacStylePrivate::initHIThemePushButton(), QRadioButton::initStyleOption(), QStyleSheetStyle::initWidget(), QStatusBar::insertPermanentWidget(), QStatusBar::insertWidget(), QSplitterPrivate::insertWidget_helper(), QWidgetPrivate::isBackgroundInherited(), QApplicationPrivate::isBlockedByModal(), isEnabledTo(), isServerProcess(), isTransient(), isWidgetOpaque(), QScreen::isWidgetPaintOnScreen(), isWindowModified(), QMdiAreaPrivate::lastWindowAboutToBeDestroyed(), QAbstractScrollAreaPrivate::layoutChildren(), QMacStyle::layoutSpacingImplementation(), lower(), make_widget_eventUPP(), make_win_eventUPP(), QWidgetBackingStore::markDirtyOnScreen(), QWinInputContext::mouseHandler(), QSizeGrip::mouseMoveEvent(), QRadioButton::mouseMoveEvent(), QCheckBox::mouseMoveEvent(), QWidgetResizeHandler::mouseMoveEvent(), QHeaderView::mouseMoveEvent(), QSizeGrip::mousePressEvent(), QGraphicsView::mouseReleaseEvent(), move(), nativeParentWidget(), QApplication::notify(), QDialog::open(), QGLOverlayWidget::paintGL(), parseGeometry(), QMacStyle::pixelMetric(), QMdiAreaPrivate::place(), QTipLabel::placeTip(), QMacStyle::polish(), QMenu::popup(), previousInFocusChain(), QWidgetPrivate::propagatePaletteChange(), q_createNativeChildrenAndSetParent(), qDeleteQGLContext(), QDialog::QDialog(), QDirectFBWindowSurface::QDirectFBWindowSurface(), qPRCleanup(), QRollEffect::QRollEffect(), qt_aqua_get_known_size(), qt_grab_cursor(), qt_keyrelease_scanner(), qt_mac_can_clickThrough(), qt_mac_get_scale_factor(), qt_mac_is_metal(), qt_mac_unregister_widget(), qt_mac_update_intersected_gl_widgets(), qt_mac_update_widget_position(), qt_mac_updateCursorWithWidgetUnderMouse(), qt_net_update_user_time(), qt_qpa_set_cursor(), qt_show_system_menu(), qt_try_modal(), qt_win_get_existing_directory(), qt_win_set_cursor(), qt_x11_enforce_cursor(), qt_x11_wait_for_window_manager(), QtWndProc(), qWinProcessConfigRequests(), QWorkspaceChild::QWorkspaceChild(), raise(), QWinInputContext::reconvertString(), releaseDC(), repaint(), QWinInputContext::reset(), resize(), QWorkspaceChild::resizeEvent(), QWidgetPrivate::scroll_sys(), QWidgetPrivate::scrollChildren(), QApplicationPrivate::sendMouseEvent(), QWSServerPrivate::sendMouseEventUnfiltered(), sendResizeEvents(), setAttribute(), QWidgetAction::setDefaultWidget(), QComboBox::setEditable(), QWidgetPrivate::setEnabled_helper(), setFocus(), QInputContext::setFocusWidget(), QApplicationPrivate::setFocusWidget(), QFrame::setFrameStyle(), QWSWindowSurface::setGeometry(), setGeometry(), setLayoutDirection(), QWidgetPrivate::setLayoutDirection_helper(), QWidgetPrivate::setLocale_helper(), setMask(), setMaximumSize(), setMinimumSize(), QWidgetPrivate::setModal_sys(), QSplitter::setOrientation(), QProgressBar::setOrientation(), QAbstractSlider::setOrientation(), setParent(), QWidgetPrivate::setParent_sys(), QApplication::setStyle(), setStyleSheet(), QMainWindow::setUnifiedTitleAndToolBarOnMac(), QWidgetPrivate::setUpdatesEnabled_helper(), QDialog::setVisible(), QColorDialog::setVisible(), QFontDialog::setVisible(), setVisible(), QScrollArea::setWidget(), QMdiSubWindow::setWidget(), QGraphicsProxyWidgetPrivate::setWidget_helper(), setWindowFlags(), setWindowOpacity(), QWidgetPrivate::show_sys(), QWidgetPrivate::showChildren(), QDialog::showEvent(), QMdiArea::showEvent(), QDialog::showExtension(), QSystemTrayIconSys::showMessage(), QComboBox::showPopup(), QWidgetBackingStore::showYellowThing(), QMacStyle::sizeFromContents(), QSoftKeyManager::softkeySource(), stackUnder(), QWinInputContext::startComposition(), QAccessibleWidget::state(), QAccessibleMenuItem::state(), QAccessibleTitleBar::state(), QWidgetBackingStore::staticContents(), QMacStyle::subControlRect(), QKeyMapperPrivate::translateKeyEvent(), QETWidget::translateMouseEvent(), QSystemTrayIconSys::trayMessage(), QGLContext::tryVisual(), QMacStyle::unpolish(), QStyleSheetStyle::unpolish(), unsetLayoutDirection(), QWinInputContext::update(), update(), QWidgetPrivate::updateFont(), QWinInputContext::updateImeStatus(), QDirectFBWindowSurface::updateIsOpaque(), QWidgetBackingStore::updateLists(), QGraphicsProxyWidgetPrivate::updateProxyInputMethodAcceptanceFromWidget(), QStyleSheetStyle::updateStyleSheetFont(), QApplication::widgetAt(), QMacStyle::widgetSizePolicy(), QApplication::winFocus(), winId(), QApplication::x11ClientMessage(), QXIMInputContext::x11FilterEvent(), QApplication::x11ProcessEvent(), xdndEnable(), QToolBar::~QToolBar(), and ~QWidget().

1042 {
1043  if (attribute < int(8*sizeof(uint)))
1044  return data->widget_attributes & (1<<attribute);
1045  return testAttribute_helper(attribute);
1046 }
uint widget_attributes
Definition: qwidget.h:118
QWidgetData * data
Definition: qwidget.h:815
unsigned int uint
Definition: qglobal.h:996
bool testAttribute_helper(Qt::WidgetAttribute) const
Definition: qwidget.cpp:11453

◆ testAttribute_helper()

bool QWidget::testAttribute_helper ( Qt::WidgetAttribute  attribute) const
private

Definition at line 11453 of file qwidget.cpp.

Referenced by focusPreviousChild().

11454 {
11455  Q_D(const QWidget);
11456  const int x = attribute - 8*sizeof(uint);
11457  const int int_off = x / (8*sizeof(uint));
11458  return (d->high_attributes[int_off] & (1<<(x-(int_off*8*sizeof(uint)))));
11459 }
double d
Definition: qnumeric_p.h:62
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_D(Class)
Definition: qglobal.h:2482
unsigned int uint
Definition: qglobal.h:996
int x() const

◆ toolTip()

QString QWidget::toolTip ( ) const

◆ topLevelWidget()

QWidget * QWidget::topLevelWidget ( ) const
inline

Use window() instead.

Definition at line 328 of file qwidget.h.

328 { return window(); }
QWidget * window() const
Returns the window for this widget, i.e.
Definition: qwidget.cpp:4492

◆ underMouse()

bool QWidget::underMouse ( ) const
inline

Returns true if the widget is under the mouse cursor; otherwise returns false.

This value is not updated properly during drag and drop operations.

See also
enterEvent(), leaveEvent()

Definition at line 996 of file qwidget.h.

Referenced by QToolBar::event(), QStyleOption::init(), QRadioButton::initStyleOption(), QRadioButton::mouseMoveEvent(), QCheckBox::mouseMoveEvent(), QCommandLinkButton::paintEvent(), QVistaBackButton::paintEvent(), QDockWidgetTitleButton::paintEvent(), CloseButton::paintEvent(), qt_qpa_set_cursor(), qt_win_set_cursor(), QtWndProc(), QGraphicsItem::setCursor(), QBalloonTip::timerEvent(), and QGraphicsItem::unsetCursor().

997 { return testAttribute(Qt::WA_UnderMouse); }
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041

◆ ungrabGesture()

void QWidget::ungrabGesture ( Qt::GestureType  gesture)

Unsubscribes the widget from a given gesture type.

See also
grabGesture(), QGestureEvent
Since
4.6

Definition at line 12977 of file qwidget.cpp.

Referenced by QGraphicsScenePrivate::ungrabGesture(), and ~QWidget().

12978 {
12979  Q_D(QWidget);
12980  if (d->gestureContext.remove(gesture)) {
12981  if (QGestureManager *manager = QGestureManager::instance())
12982  manager->cleanupCachedGestures(this, gesture);
12983  }
12984 }
double d
Definition: qnumeric_p.h:62
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_D(Class)
Definition: qglobal.h:2482
static QGestureManager * instance()

◆ unsetCursor()

void QWidget::unsetCursor ( )

Definition at line 5311 of file qwidget.cpp.

Referenced by QToolBar::event(), QHeaderView::mouseMoveEvent(), QGraphicsView::setDragMode(), and QGraphicsProxyWidgetPrivate::setWidget_helper().

5312 {
5313  Q_D(QWidget);
5314  if (d->extra) {
5315  delete d->extra->curs;
5316  d->extra->curs = 0;
5317  }
5318  if (!isWindow())
5320  d->unsetCursor_sys();
5321 
5324 }
double d
Definition: qnumeric_p.h:62
bool isWindow() const
Returns true if the widget is an independent window, otherwise returns false.
Definition: qwidget.h:945
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_D(Class)
Definition: qglobal.h:2482
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
void setAttribute(Qt::WidgetAttribute, bool on=true)
Sets the attribute attribute on this widget if on is true; otherwise clears the attribute.
Definition: qwidget.cpp:11087
bool event(QEvent *)
This is the main event handler; it handles event event.
Definition: qwidget.cpp:8636
The QEvent class is the base class of all event classes.
Definition: qcoreevent.h:56

◆ unsetLayoutDirection()

void QWidget::unsetLayoutDirection ( )

Definition at line 5217 of file qwidget.cpp.

Referenced by setLayoutDirection().

5218 {
5219  Q_D(QWidget);
5221  d->resolveLayoutDirection();
5222 }
double d
Definition: qnumeric_p.h:62
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_D(Class)
Definition: qglobal.h:2482
void setAttribute(Qt::WidgetAttribute, bool on=true)
Sets the attribute attribute on this widget if on is true; otherwise clears the attribute.
Definition: qwidget.cpp:11087

◆ unsetLocale()

void QWidget::unsetLocale ( )

Definition at line 6178 of file qwidget.cpp.

6179 {
6180  Q_D(QWidget);
6182  d->resolveLocale();
6183 }
double d
Definition: qnumeric_p.h:62
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_D(Class)
Definition: qglobal.h:2482
void setAttribute(Qt::WidgetAttribute, bool on=true)
Sets the attribute attribute on this widget if on is true; otherwise clears the attribute.
Definition: qwidget.cpp:11087

◆ update [1/4]

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.

Calling update() several times normally results in just one paintEvent() call.

Qt normally erases the widget's area before the paintEvent() call. If the Qt::WA_OpaquePaintEvent widget attribute is set, the widget is responsible for painting all its pixels with an opaque color.

See also
repaint() paintEvent(), setUpdatesEnabled(), {Analog Clock Example}

Definition at line 10883 of file qwidget.cpp.

Referenced by QTextEditPrivate::_q_adjustScrollbars(), QTreeViewPrivate::_q_endAnimatedOperation(), QHeaderViewPrivate::_q_layoutChanged(), QToolButtonPrivate::_q_menuTriggered(), QTextEditPrivate::_q_repaintContents(), QPlainTextEditPrivate::_q_repaintContents(), QHeaderViewPrivate::_q_sectionsRemoved(), QMenuBar::actionEvent(), QMenu::actionEvent(), QMainWindowLayout::animationFinished(), QHeaderViewPrivate::cascadingResize(), QDockWidget::changeEvent(), QLineEdit::changeEvent(), changeEvent(), QTreeView::collapse(), QTreeView::columnCountChanged(), QTreeView::currentChanged(), QAbstractItemView::currentChanged(), QAbstractItemView::dataChanged(), QScriptEdit::deleteBreakpoint(), QIconModeViewBase::doDynamicLayout(), QListModeViewBase::doStaticLayout(), QLineEdit::dragLeaveEvent(), QLineEdit::dragMoveEvent(), QLineEdit::dropEvent(), QColorWell::dropEvent(), QAbstractItemView::edit(), QWidgetEffectSourcePrivate::effectBoundingRectChanged(), QLabelPrivate::ensureTextControl(), QVistaBackButton::enterEvent(), QToolButton::enterEvent(), QDockWidgetTitleButton::enterEvent(), CloseButton::enterEvent(), QWorkspaceTitleBar::enterEvent(), QGroupBox::event(), QStatusBar::event(), QMdiSubWindow::event(), QDockWidget::event(), QSplitterHandle::event(), QTabBar::event(), QWorkspaceTitleBar::event(), QAbstractItemView::event(), event(), QAlphaWidget::eventFilter(), QWindowsStyle::eventFilter(), QMdiSubWindow::eventFilter(), QX11EmbedContainer::eventFilter(), QWorkspaceChild::eventFilter(), QTreeViewPrivate::expandOrCollapseItemAtPos(), QIconModeViewBase::filterDragLeaveEvent(), QIconModeViewBase::filterDragMoveEvent(), QIconModeViewBase::filterDropEvent(), QSidebar::focusInEvent(), QLineEdit::focusInEvent(), QComboBox::focusInEvent(), focusInEvent(), QApplicationPrivate::focusNextPrevChild_helper(), QLineEdit::focusOutEvent(), QComboBox::focusOutEvent(), focusOutEvent(), QVistaHelper::handleWinEvent(), QComboBoxPrivateContainer::hideEvent(), QMainWindowLayout::hover(), QLineEditPrivate::init(), QDateTimeEdit::keyPressEvent(), QVistaBackButton::leaveEvent(), QMDIControl::leaveEvent(), QToolButton::leaveEvent(), QMdiSubWindow::leaveEvent(), QDockWidgetTitleButton::leaveEvent(), CloseButton::leaveEvent(), QWorkspaceTitleBar::leaveEvent(), QMdi::ControllerWidget::leaveEvent(), QTreeView::mouseDoubleClickEvent(), QRadioButton::mouseMoveEvent(), QScrollBar::mouseMoveEvent(), QCheckBox::mouseMoveEvent(), QMDIControl::mouseMoveEvent(), QGroupBox::mouseMoveEvent(), QMdiSubWindow::mouseMoveEvent(), QTabBar::mouseMoveEvent(), QGraphicsView::mouseMoveEvent(), QWorkspaceTitleBar::mouseMoveEvent(), QMdi::ControllerWidget::mouseMoveEvent(), QMDIControl::mousePressEvent(), QGroupBox::mousePressEvent(), QSlider::mousePressEvent(), QMdiSubWindow::mousePressEvent(), QMenuBar::mousePressEvent(), QMenu::mousePressEvent(), QSplitterHandle::mousePressEvent(), QWorkspaceTitleBar::mousePressEvent(), QMdi::ControllerWidget::mousePressEvent(), QMDIControl::mouseReleaseEvent(), QGroupBox::mouseReleaseEvent(), QSlider::mouseReleaseEvent(), QMdiSubWindow::mouseReleaseEvent(), QSplitterHandle::mouseReleaseEvent(), QGraphicsView::mouseReleaseEvent(), QWorkspaceTitleBar::mouseReleaseEvent(), QAbstractItemView::mouseReleaseEvent(), QMdi::ControllerWidget::mouseReleaseEvent(), QTreeView::moveCursor(), QTabBar::moveTab(), QGraphicsViewPrivate::processPendingUpdates(), QSvgWidget::QSvgWidget(), qt_cleanup(), qt_mac_update_widget_position(), qt_mac_updateParentUnderAlienWidget(), QtWndProc(), QStatusBar::reformat(), QMdi::ControlContainer::removeButtonsFromMenuBar(), repaint(), QAbstractSpinBox::resizeEvent(), QHeaderViewPrivate::resizeSections(), QBBGLContext::resizeSurface(), QTreeView::rowsInserted(), QAbstractScrollArea::scrollContentsBy(), QTreeView::scrollContentsBy(), QGraphicsView::scrollContentsBy(), QIconModeViewBase::scrollContentsBy(), QTableView::scrollTo(), QWorkspaceTitleBar::setActive(), QWorkspaceChild::setActive(), QGroupBox::setAlignment(), QLineEdit::setAlignment(), QToolButton::setArrowType(), QPushButton::setAutoDefault(), QToolButton::setAutoRaise(), QWorkspace::setBackground(), QMdiArea::setBackground(), QGraphicsScene::setBackgroundBrush(), QScriptEdit::setBaseLineNumber(), QScriptEdit::setBreakpoint(), QScriptEdit::setBreakpointEnabled(), QAbstractSpinBox::setButtonSymbols(), QDateTimeEdit::setCalendarPopup(), QGroupBox::setCheckable(), QGroupBox::setChecked(), QmlJSDebugger::ToolBarColorBox::setColor(), setContentsMargins(), QTabBar::setCurrentIndex(), QPushButton::setDefault(), QCommandLinkButton::setDescription(), QLCDNumber::setDigitCount(), QTabBar::setDrawBase(), QLineEdit::setEchoMode(), QScriptEdit::setExecutionLineNumber(), QDockWidget::setFeatures(), QGroupBox::setFlat(), QPushButton::setFlat(), QGraphicsScene::setForegroundBrush(), QProgressBar::setFormat(), QComboBox::setFrame(), QLineEdit::setFrame(), QAbstractSpinBox::setFrame(), QFrame::setFrameStyle(), QDirectFbWindow::setGeometry(), setGraphicsEffect(), QAbstractItemViewPrivate::setHoverIndex(), QAbstractButton::setIcon(), QAbstractButton::setIconSize(), QTabBar::setIconSize(), QProgressBar::setInvertedAppearance(), QAbstractSlider::setInvertedAppearance(), QAbstractItemView::setItemDelegate(), QAbstractItemView::setItemDelegateForColumn(), QAbstractItemView::setItemDelegateForRow(), QComboBox::setLineEdit(), setMask(), QPushButton::setMenu(), QToolButton::setMenu(), QDial::setNotchesVisible(), QDial::setNotchTarget(), QToolBarSeparator::setOrientation(), QProgressBar::setOrientation(), QAbstractSlider::setOrientation(), QShapedPixmapWidget::setPixmap(), QLineEdit::setPlaceholderText(), QProgressBar::setRange(), QAbstractSpinBox::setReadOnly(), QLineEdit::setReadOnly(), QTableView::setRootIndex(), QComboBox::setRootModelIndex(), QLabel::setScaledContents(), QLCDNumber::setSegmentStyle(), QToolBoxButton::setSelected(), QMenu::setSeparatorsCollapsible(), QAbstractSlider::setSliderPosition(), QLCDNumber::setSmallDecimalPoint(), QApplication::setStyle(), QTabBar::setTabButton(), QTabBar::setTabEnabled(), QTabBar::setTabIcon(), QTabBar::setTabsClosable(), QTabBar::setTabTextColor(), QAbstractButton::setText(), QProgressBar::setTextDirection(), QLineEdit::setTextMargins(), QSlider::setTickInterval(), QSlider::setTickPosition(), QGroupBox::setTitle(), QToolButton::setToolButtonStyle(), QTabWidget::setUpLayout(), QDockWidgetLayout::setVerticalTitleBar(), QGraphicsProxyWidgetPrivate::setWidget_helper(), QDial::setWrapping(), QComboBoxPrivateContainer::showEvent(), QComboBox::showPopup(), QWorkspaceChild::showShaded(), QAbstractSlider::sliderChange(), QMacStylePrivate::stopAnimate(), QWidgetBackingStore::sync(), QWindowsStyle::timerEvent(), QPlastiqueStyle::timerEvent(), QMotifStyle::timerEvent(), QMainWindowLayout::timerEvent(), QWindowsVistaStylePrivate::timerEvent(), QMacStylePrivate::timerEvent(), QWellArray::updateCell(), QTreeViewPrivate::AnimatedOperation::updateCurrentValue(), QScriptEdit::updateExtraArea(), QUIKitWindow::updateGeometryAndOrientation(), QSystemTrayIconSys::updateIcon(), QGraphicsViewPrivate::updateRect(), QGraphicsView::updateScene(), QToolBoxPrivate::updateTabs(), updateWidgets(), QMdi::ControlLabel::updateWindowIcon(), QTreeView::viewportEvent(), and QX11EmbedContainer::x11Event().

10884 {
10885  update(rect());
10886 }
void update()
Updates the widget unless updates are disabled or the widget is hidden.
Definition: qwidget.cpp:10883
QRect rect() const

◆ update() [2/4]

void QWidget::update ( int  x,
int  y,
int  w,
int  h 
)
inline

This version updates a rectangle (x, y, w, h) inside the widget.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 1002 of file qwidget.h.

1003 { update(QRect(ax, ay, aw, ah)); }
void update()
Updates the widget unless updates are disabled or the widget is hidden.
Definition: qwidget.cpp:10883
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58

◆ update() [3/4]

void QWidget::update ( const QRect rect)

This version updates a rectangle rect inside the widget.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 10906 of file qwidget.cpp.

10907 {
10908  if (!isVisible() || !updatesEnabled())
10909  return;
10910 
10911  QRect r = rect & QWidget::rect();
10912 
10913  if (r.isEmpty())
10914  return;
10915 
10918  return;
10919  }
10920 
10921  if (hasBackingStoreSupport()) {
10922 #ifdef QT_MAC_USE_COCOA
10923  if (qt_widget_private(this)->isInUnifiedToolbar) {
10924  qt_widget_private(this)->unifiedSurface->renderToolbar(this, true);
10925  return;
10926  }
10927 #endif // QT_MAC_USE_COCOA
10928  QTLWExtra *tlwExtra = window()->d_func()->maybeTopData();
10929  if (tlwExtra && !tlwExtra->inTopLevelResize && tlwExtra->backingStore)
10930  tlwExtra->backingStore->markDirty(r, this);
10931  } else {
10932  d_func()->repaint_sys(r);
10933  }
10934 }
static bool hasBackingStoreSupport()
Definition: qwidget.cpp:169
static void postEvent(QObject *receiver, QEvent *event)
Adds the event event, with the object receiver as the receiver of the event, to an event queue and re...
bool isVisible() const
Definition: qwidget.h:1005
uint inTopLevelResize
Definition: qwidget_p.h:188
bool updatesEnabled() const
void markDirty(const QRegion &rgn, QWidget *widget, bool updateImmediately=false, bool invalidateBuffer=false)
Marks the region of the widget as dirty (if not already marked as dirty) and posts an UpdateRequest e...
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
QRect rect() const
bool isEmpty() const
Returns true if the rectangle is empty, otherwise returns false.
Definition: qrect.h:234
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
QWidget * window() const
Returns the window for this widget, i.e.
Definition: qwidget.cpp:4492
friend Q_GUI_EXPORT QWidgetPrivate * qt_widget_private(QWidget *widget)
Definition: qwidget.cpp:12920
QWidgetBackingStoreTracker backingStore
Definition: qwidget_p.h:166

◆ update() [4/4]

void QWidget::update ( const QRegion rgn)

This version repaints a region rgn inside the widget.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 10944 of file qwidget.cpp.

10945 {
10946  if (!isVisible() || !updatesEnabled() || rgn.isEmpty())
10947  return;
10948 
10949  QRegion r = rgn & QWidget::rect();
10950 
10951  if (r.isEmpty())
10952  return;
10953 
10956  return;
10957  }
10958 
10959  if (hasBackingStoreSupport()) {
10960 #ifdef QT_MAC_USE_COCOA
10961  if (qt_widget_private(this)->isInUnifiedToolbar) {
10962  qt_widget_private(this)->unifiedSurface->renderToolbar(this, true);
10963  return;
10964  }
10965 #endif // QT_MAC_USE_COCOA
10966  QTLWExtra *tlwExtra = window()->d_func()->maybeTopData();
10967  if (tlwExtra && !tlwExtra->inTopLevelResize && tlwExtra->backingStore)
10968  tlwExtra->backingStore->markDirty(r, this);
10969  } else {
10970  d_func()->repaint_sys(r);
10971  }
10972 }
static bool hasBackingStoreSupport()
Definition: qwidget.cpp:169
static void postEvent(QObject *receiver, QEvent *event)
Adds the event event, with the object receiver as the receiver of the event, to an event queue and re...
bool isVisible() const
Definition: qwidget.h:1005
uint inTopLevelResize
Definition: qwidget_p.h:188
bool updatesEnabled() const
void markDirty(const QRegion &rgn, QWidget *widget, bool updateImmediately=false, bool invalidateBuffer=false)
Marks the region of the widget as dirty (if not already marked as dirty) and posts an UpdateRequest e...
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
bool isEmpty() const
Returns true if the region is empty; otherwise returns false.
Definition: qregion.cpp:4098
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
QRect rect() const
QWidget * window() const
Returns the window for this widget, i.e.
Definition: qwidget.cpp:4492
friend Q_GUI_EXPORT QWidgetPrivate * qt_widget_private(QWidget *widget)
Definition: qwidget.cpp:12920
QWidgetBackingStoreTracker backingStore
Definition: qwidget_p.h:166

◆ updateGeometry()

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.

Definition at line 10372 of file qwidget.cpp.

Referenced by QLayout::activate(), QBalloonTip::balloon(), changeEvent(), QPushButton::event(), QX11EmbedContainer::eventFilter(), qt_set_windows_updateScrollBar(), QTabBar::resizeEvent(), QGroupBox::setAlignment(), QToolButton::setArrowType(), QPushButton::setAutoDefault(), QGroupBox::setCheckable(), setContentsMargins(), QCommandLinkButton::setDescription(), QGroupBox::setFlat(), QPushButton::setFlat(), QComboBox::setFrame(), QLineEdit::setFrame(), QAbstractButton::setIcon(), QAbstractButton::setIconSize(), QTabBar::setIconSize(), QComboBox::setIconSize(), QPushButton::setMenu(), QComboBox::setMinimumContentsLength(), QMenuBar::setNativeMenuBar(), QCalendarWidget::setNavigationBarVisible(), QProgressBar::setOrientation(), QAbstractSlider::setOrientation(), QSpinBox::setPrefix(), QComboBox::setSizeAdjustPolicy(), setSizePolicy(), QSpinBox::setSuffix(), QDoubleSpinBox::setSuffix(), QAbstractButton::setText(), QLineEdit::setTextMargins(), QSlider::setTickPosition(), QGroupBox::setTitle(), QToolButton::setToolButtonStyle(), QWizardHeader::setup(), QTabWidget::setUpLayout(), QScrollArea::setWidgetResizable(), QWizard::setWizardStyle(), QComboBox::showEvent(), updateWidgets(), and QX11EmbedContainer::x11Event().

10373 {
10374  Q_D(QWidget);
10375  d->updateGeometry_helper(false);
10376 }
double d
Definition: qnumeric_p.h:62
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_D(Class)
Definition: qglobal.h:2482

◆ updateMicroFocus

void QWidget::updateMicroFocus ( )
protectedslot

Updates the widget's micro focus.

See also
QInputContext

Definition at line 11820 of file qwidget.cpp.

Referenced by QLineEditPrivate::init(), setShown(), QPlainTextEdit::wheelEvent(), and QTextEdit::wheelEvent().

11821 {
11822 #if !defined(QT_NO_IM) && (defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN))
11823  Q_D(QWidget);
11824  // and optimization to update input context only it has already been created.
11825  if (d->assignedInputContext() || qApp->d_func()->inputContext) {
11826  QInputContext *ic = inputContext();
11827  if (ic)
11828  ic->update();
11829  }
11830 #endif
11831 #ifndef QT_NO_ACCESSIBILITY
11832  if (isVisible()) {
11833  // ##### is this correct
11835  }
11836 #endif
11837 }
double d
Definition: qnumeric_p.h:62
static void updateAccessibility(QObject *, int who, Event reason)
Notifies accessibility clients about a change in object&#39;s accessibility information.
bool isVisible() const
Definition: qwidget.h:1005
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_D(Class)
Definition: qglobal.h:2482
virtual void update()
This virtual function is called when a state in the focus widget has changed.
#define qApp
QInputContext * inputContext()
This function returns the QInputContext for this widget.
Definition: qwidget.cpp:474
The QInputContext class abstracts the input method dependent data and composing state.
Definition: qinputcontext.h:83

◆ updatesEnabled()

bool QWidget::updatesEnabled ( ) const
inline

◆ visibleRegion()

QRegion QWidget::visibleRegion ( ) 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.

The repaint() function calls this function if necessary, so in general you do not need to call it.

Definition at line 8404 of file qwidget.cpp.

8405 {
8406  Q_D(const QWidget);
8407 
8408  QRect clipRect = d->clipRect();
8409  if (clipRect.isEmpty())
8410  return QRegion();
8411  QRegion r(clipRect);
8412  d->subtractOpaqueChildren(r, clipRect);
8413  d->subtractOpaqueSiblings(r);
8414 #ifdef Q_WS_QWS
8415  const QWSWindowSurface *surface = static_cast<const QWSWindowSurface*>(windowSurface());
8416  if (surface) {
8417  const QPoint offset = mapTo(surface->window(), QPoint());
8418  r &= surface->clipRegion().translated(-offset);
8419  }
8420 #endif
8421  return r;
8422 }
double d
Definition: qnumeric_p.h:62
The QWSWindowSurface class provides the drawing area for top-level windows in Qt for Embedded Linux...
const QRegion clipRegion() const
Returns the region currently visible on the screen.
QPoint mapTo(QWidget *, const QPoint &) const
Translates the widget coordinate pos to the coordinate system of parent.
Definition: qwidget.cpp:4409
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_D(Class)
Definition: qglobal.h:2482
QWindowSurface * windowSurface() const
Returns the QWindowSurface this widget will be drawn into.
Definition: qwidget.cpp:12819
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
bool isEmpty() const
Returns true if the rectangle is empty, otherwise returns false.
Definition: qrect.h:234
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
QRegion translated(int dx, int dy) const
Returns a copy of the region that is translated dx along the x axis and dy along the y axis...
Definition: qregion.cpp:743
QWidget * window() const
Returns a pointer to the top-level window associated with this surface.

◆ whatsThis()

QString QWidget::whatsThis ( ) const

◆ wheelEvent()

void QWidget::wheelEvent ( QWheelEvent event)
protectedvirtual

This event handler, for event event, can be reimplemented in a subclass to receive wheel events for the widget.

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
QWheelEvent::ignore(), QWheelEvent::accept(), event(), QWheelEvent

Reimplemented in QCalendarView, QTextEdit, QGraphicsView, QComboBox, QPlainTextEdit, QTabBar, QDateTimeEdit, QSystemTrayIconSys, QMenu, QAbstractSlider, QAbstractSpinBox, QWorkspace, and QAbstractScrollArea.

Definition at line 9326 of file qwidget.cpp.

Referenced by QComboBox::addItems(), event(), setShown(), and QTabBar::wheelEvent().

9327 {
9328  event->ignore();
9329 }

◆ width()

int QWidget::width ( ) const
inline

Referenced by QWorkspacePrivate::_q_scrollBarChanged(), QCalendarWidgetPrivate::_q_yearClicked(), QSplitterPrivate::adjustPos(), QDialog::adjustPosition(), QApplicationPrivate::applyX11SpecificCommandLineArguments(), QWorkspace::cascade(), QGraphicsView::centerOn(), QMenuBar::changeEvent(), QTableView::columnMoved(), QAbstractSpinBox::contextMenuEvent(), QTreeView::currentChanged(), QWSDisplay::defineCursor(), QColumnViewPrivate::doLayout(), QTreeView::drawRow(), QLCDNumberPrivate::drawSegment(), QVistaHelper::drawTitleBar(), QLabelPrivate::ensureTextLayouted(), QGraphicsView::ensureVisible(), QFontComboBox::event(), QMdiSubWindow::event(), QWizard::event(), QWorkspace::eventFilter(), QMdiSubWindow::eventFilter(), QWorkspaceChild::eventFilter(), QScriptEdit::extraAreaPaintEvent(), QWizardPrivate::findDefaultBackgroundPixmap(), QColorDialogPrivate::init(), inputMethodQuery(), QMenu::keyPressEvent(), QMdiSubWindow::leaveEvent(), QStatusBarPrivate::messageRect(), QMdiSubWindow::minimumSizeHint(), QDialog::minimumSizeHint(), QProgressBar::minimumSizeHint(), QMenuBar::minimumSizeHint(), QCalendarWidget::minimumSizeHint(), QTabBar::minimumSizeHint(), QToolBarPrivate::mouseMoveEvent(), QMdiSubWindow::mouseMoveEvent(), QMdiSubWindow::mousePressEvent(), QMdiSubWindow::mouseReleaseEvent(), QTabBar::mouseReleaseEvent(), QRubberBand::move(), move(), QTabBar::moveTab(), QAxClientSite::OnPosRectChange(), QWorkspace::paintEvent(), QMdiSubWindow::paintEvent(), QMenuBar::paintEvent(), QMenu::paintEvent(), QWizard::paintEvent(), QTabBar::paintEvent(), QHeaderView::paintEvent(), QWizardHeader::paintEvent(), QWizardAntiFlickerWidget::paintEvent(), QColorLuminancePicker::paintEvent(), QGLOverlayWidget::paintGL(), QMdiAreaPrivate::place(), QTipLabel::placeTip(), QScriptDebuggerCodeFinderWidget::QScriptDebuggerCodeFinderWidget(), QtWndProc(), QWhatsThat::QWhatsThat(), QAccessibleTable2::rect(), QAccessibleHeader::rect(), QAccessibleItemView::rect(), QAccessibleSlider::rect(), QAccessibleDial::rect(), QAccessibleTable2HeaderCell::rect(), QTextEditPrivate::relayoutDocument(), QPlainTextEditPrivate::relayoutDocument(), QComboBoxListView::resizeEvent(), QVistaHelper::resizeEvent(), QX11EmbedContainer::resizeEvent(), QMdiSubWindow::resizeEvent(), QColorPicker::resizeEvent(), QWorkspaceChild::resizeEvent(), QAxHostWidget::resizeObject(), QExpandingLineEdit::resizeToContents(), QMdiAreaPrivate::resizeToMinimumTileSize(), QWhatsThisPrivate::say(), QColumnView::scrollTo(), QProgressDialog::setBar(), QProgressDialog::setCancelButton(), QProgressDialog::setCancelButtonText(), QmlJSDebugger::ToolBarColorBox::setColor(), setFixedHeight(), setGeometry(), QSplitter::setHandleWidth(), QProgressDialog::setLabel(), QProgressDialog::setLabelText(), setMaximumHeight(), setMaximumSize(), setMinimumHeight(), setMinimumSize(), QListView::setSelection(), QMdiSubWindowPrivate::setSizeGrip(), QWizardHeader::setup(), QProgressDialog::setValue(), QVistaHelper::setWindowPosHack(), QDial::setWrapping(), QProgressDialog::showEvent(), QWhatsThat::showEvent(), QDialog::showExtension(), QComboBox::showPopup(), QWorkspaceChild::showShaded(), QVistaBackButton::sizeHint(), QDialog::sizeHint(), QProgressDialog::sizeHint(), QMenuBar::sizeHint(), CloseButton::sizeHint(), QFileDialogListView::sizeHint(), QTableView::sizeHintForColumn(), QAbstractItemView::sizeHintForColumn(), QWorkspace::tile(), QScriptEdit::updateExtraArea(), QTableView::updateGeometries(), QListView::updateGeometries(), QExpandingLineEdit::updateMinimumWidth(), QTreeViewPrivate::updateScrollBars(), QMessageBoxPrivate::updateSize(), QMdiAreaPrivate::updateTabBarGeometry(), QTreeView::viewportEvent(), QTableView::visualRegionForSelection(), QHeaderView::visualRegionForSelection(), and windowInteractsWithPosition().

◆ window()

QWidget * QWidget::window ( ) const

Returns the window for this widget, i.e.

the next ancestor widget that has (or could have) a window-system frame.

If the widget is a window, the widget itself is returned.

Typical usage is changing the window title:

aWidget->window()->setWindowTitle("New Window Title");
See also
isWindow()

Definition at line 4492 of file qwidget.cpp.

Referenced by QX11EmbedContainerPrivate::acceptClient(), activateWindow(), QMainWindow::addDockWidget(), QDialog::adjustPosition(), QApplication::alert(), alert_widget(), QMacStylePrivate::animatable(), QDockAreaLayoutInfo::apply(), QGLWindowSurface::buffer(), QWindowSurface::buffer(), QXlibCursor::changeCursor(), QX11EmbedWidgetPrivate::checkActivateWindow(), checkEmbedded(), clearMask(), QApplicationPrivate::closePopup(), QUIKitSoftwareInputHandler::closeSoftwareInputPanel(), QShortcutMap::correctGraphicsWidgetContext(), QShortcutMap::correctWidgetContext(), QFileDialogPrivate::createNavServicesDialog(), QMdiArea::currentSubWindow(), destroy(), QApplicationPrivate::dispatchEnterLeave(), QX11Data::dndEnable(), QWindowsXPStylePrivate::drawBackground(), QTreeView::drawBranches(), QMacStyle::drawControl(), QVistaHelper::drawTitleBar(), QWinInputContext::enablePopupChild(), QFontComboBox::event(), QStatusBar::event(), QMdiSubWindow::event(), QAbstractButton::event(), QLabel::event(), QMdiArea::event(), QApplication::event(), QUIKitSoftwareInputHandler::eventFilter(), QWindowsStyle::eventFilter(), QWorkspace::eventFilter(), QX11EmbedContainer::eventFilter(), QAxHostWidget::eventFilter(), QCalendarWidget::eventFilter(), QMdiArea::eventFilter(), QMacStylePrivate::eventFilter(), QX11Data::findClientWindow(), findParentforPopup(), findRealWindow(), flipPoint(), QXcbWindowSurface::flush(), QRasterWindowSurface::flush(), QPushButton::focusInEvent(), QApplicationPrivate::focusNextPrevChild_helper(), QPushButton::focusOutEvent(), QWidgetPrivate::frameStrut(), getNetWmState(), QAxClientSite::GetWindowContext(), QApplicationPrivate::globalEventProcessor(), QWSDisplay::grabKeyboard(), QWSDisplay::grabMouse(), QWindowSurface::grabWidget(), QMenuBarPrivate::handleReparent(), hasFocus(), QWindowsStylePrivate::hasSeenAlt(), QWidgetPrivate::hide_sys(), QStyleOption::init(), QMenu::initStyleOption(), QKeyMapperPrivate::isADeadKey(), QApplicationPrivate::isBlockedByModal(), isInPopup(), QApplication::isLeftToRight(), isServerProcess(), QAbstractScrollAreaPrivate::layoutChildren(), QMenuBarPrivate::macDestroyMenuBar(), QCoreGraphicsPaintEngine::macDisplayColorSpace(), QMenuBarPrivate::macWidgetHasNativeMenubar(), make_widget_eventUPP(), make_win_eventUPP(), QWidgetBackingStore::markDirty(), menuItemEntry(), QToolBarPrivate::mouseMoveEvent(), QAbstractButtonPrivate::moveFocus(), QWidgetPrivate::moveRect(), QApplication::notify(), QApplicationPrivate::notify_helper(), QAxClientSite::OnPosRectChange(), QPrintDialogPrivate::openWindowsPrintDialogModally(), QWizardAntiFlickerWidget::paintEvent(), QGLOverlayWidget::paintGL(), QHeaderView::paintSection(), QMacStyle::pixelMetric(), QPlatformScreen::platformScreenForWidget(), QMenu::popup(), QWidgetPrivate::prepareToRender(), previousInFocusChain(), q_createNativeChildrenAndSetParent(), qCanAllocColors(), QDirectFBWindowSurface::QDirectFBWindowSurface(), qstring_to_xtp(), qt_aqua_guess_size(), qt_cleanup(), qt_mac_desktopSize(), qt_mac_get_scale_factor(), qt_mac_handleTabletEvent(), qt_mac_unregister_widget(), qt_mac_update_intersected_gl_widgets(), qt_mac_update_widget_position(), qt_mac_window_for(), QAxClientSite::qt_metacall(), qt_qpa_set_cursor(), qt_win_get_existing_directory(), qt_win_get_save_file_name(), qt_win_getKeyboardModifiers(), qt_win_make_OFN(), qt_win_set_cursor(), qt_win_setup_PRINTDLGEX(), QtWndProc(), QWorkspaceChild::QWorkspaceChild(), QApplication::qwsProcessEvent(), QX11EmbedContainer::QX11EmbedContainer(), QX11EmbedContainerPrivate::QX11EmbedContainerPrivate(), QXcbWindow::QXcbWindow(), QX11EmbedContainerPrivate::rejectClient(), QMdi::ControlContainer::removeButtonsFromMenuBar(), QMdiSubWindowPrivate::removeButtonsFromMenuBar(), repaint(), QWidgetPrivate::reparentFocusWidgets(), QDockAreaLayoutInfo::restoreState(), QWidgetPrivate::scrollRect(), QWSDisplay::selectCursor(), QApplicationPrivate::sendSyntheticEnterLeave(), sendXEmbedMessage(), QWorkspaceChild::setActive(), QApplication::setActiveWindow(), setAttribute(), QMenuBarPrivate::setCurrentAction(), QStackedLayout::setCurrentIndex(), QDialogPrivate::setDefault(), PvrEglWindowSurface::setDirectRegion(), setFocus(), QWSInputContext::setFocusWidget(), QApplicationPrivate::setFocusWidget(), QWidgetPrivate::setModal_sys(), setParent(), QWidgetPrivate::setParent_sys(), QDeclarativeView::setRootObject(), QmlJSDebugger::AbstractViewInspector::setShowAppOnTop(), setTabOrder(), QGtkStylePrivate::setupGtkFileChooser(), QDialog::setVisible(), QXlibWindow::setVisible(), setVisible(), QMdiSubWindowPrivate::showButtonsInMenuBar(), QMdiArea::showEvent(), QComboBox::showPopup(), QDirectFBScreen::surfaceForWidget(), QApplication::syncX(), QMacStylePrivate::timerEvent(), QWorkspaceTitleBarPrivate::titleBarState(), QAxServerBase::TranslateAcceleratorW(), QWSInputContext::translateIMQueryEvent(), QETWidget::translateWheelEvent(), QApplicationPrivate::tryModalHelper(), QWidgetBackingStore::unflushPaint(), QWSInputContext::update(), update(), QMenuBarPrivate::updateCornerWidgetToolBar(), QGLContext::updatePaintDevice(), updateRedirectedToGraphicsProxyWidget(), QWSEmbedWidgetPrivate::updateWindow(), QWorkspaceTitleBar::usesActiveColor(), QGraphicsView::viewportEvent(), QAxScriptSite::window(), QApplication::winFocus(), QX11EmbedWidget::x11Event(), QApplication::x11ProcessEvent(), xdndEnable(), QX11Data::xdndHandleDrop(), and QX11Data::xdndHandleLeave().

4493 {
4494  QWidget *w = (QWidget *)this;
4495  QWidget *p = w->parentWidget();
4496  while (!w->isWindow() && p) {
4497  w = p;
4498  p = p->parentWidget();
4499  }
4500  return w;
4501 }
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
bool isWindow() const
Returns true if the widget is an independent window, otherwise returns false.
Definition: qwidget.h:945
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150

◆ windowActivationChange()

void QWidget::windowActivationChange ( bool  )
protectedvirtual
Warning
This function is not part of the public interface.

Definition at line 12004 of file qwidget.cpp.

Referenced by event(), and QAxClientSite::translateKeyEvent().

12004 { } // compat

◆ windowFilePath()

QString QWidget::windowFilePath ( ) const

Referenced by setWindowFilePath(), and setWindowIcon().

◆ windowFlags()

Qt::WindowFlags QWidget::windowFlags ( ) const
inline

Window flags are a combination of a type (e.

g. Qt::Dialog) and zero or more hints to the window system (e.g. Qt::FramelessWindowHint).

If the widget had type Qt::Widget or Qt::SubWindow and becomes a window (Qt::Window, Qt::Dialog, etc.), it is put at position (0, 0) on the desktop. If the widget is a window and becomes a Qt::Widget or Qt::SubWindow, it is put at position (0, 0) relative to its parent widget.

Note
This function calls setParent() when changing the flags for a window, causing the widget to be hidden. You must call show() to make the widget visible again..
See also
windowType(), {Window Flags Example}

Definition at line 939 of file qwidget.h.

Referenced by QWorkspacePrivate::_q_updateActions(), QMdiArea::addSubWindow(), QMdiAreaPrivate::appendChild(), bypassGraphicsProxyWidget(), QRubberBand::changeEvent(), QGraphicsProxyWidgetPrivate::embedSubWindow(), QMdiSubWindow::event(), QWorkspaceChild::eventFilter(), QDialog::exec(), flipPoint(), QWSWindowSurface::flush(), getNamedAttribute(), getNetWmState(), QMdiAreaPrivate::highlightNextSubWindow(), QWorkspaceChild::internalRaise(), isPopup(), isServerProcess(), make_widget_eventUPP(), QWorkspacePrivate::maximizeWindow(), QWorkspacePrivate::minimizeWindow(), QMdiSubWindow::mouseDoubleClickEvent(), QSizeGrip::mouseMoveEvent(), QSizeGrip::mousePressEvent(), QDecorationWindows::paint(), QDecorationStyled::paint(), QDecorationDefault::paint(), QMdiSubWindow::paintEvent(), QDialog::QDialog(), qstring_to_xtp(), qt_mac_QStringListToNSMutableArrayVoid(), qt_mac_unregister_widget(), qt_mac_updateToolBarButtonHint(), qt_show_system_menu(), qt_wince_maximize(), qt_wince_unmaximize(), qt_x11_recreateWidget(), QtWndProc(), QWizard::QWizard(), QWorkspaceChild::QWorkspaceChild(), QWorkspaceTitleBar::QWorkspaceTitleBar(), QApplication::qwsProcessEvent(), QXcbWindow::QXcbWindow(), QMdiAreaPrivate::rearrange(), QDecorationStyled::region(), QDecorationWindows::region(), QDecorationDefault::region(), QWSDisplay::repaintRegion(), setParent(), QmlJSDebugger::AbstractViewInspector::setShowAppOnTop(), QMdiSubWindowPrivate::setSizeGrip(), QMainWindow::setUnifiedTitleAndToolBarOnMac(), QMdiArea::setupViewport(), QMdi::ControlContainer::showButtonsInMenuBar(), QMdiSubWindow::showEvent(), QWorkspacePrivate::showWindow(), QAccessibleWidget::state(), QWorkspace::tile(), QWorkspaceChild::titleBarDoubleClicked(), QDecorationStyled::titleBarHeight(), QWorkspaceChild::updateMask(), updateRedirectedToGraphicsProxyWidget(), QMdiAreaPrivate::windowStaysOnTop(), and QApplication::winFocus().

940 { return data->window_flags; }
Qt::WindowFlags window_flags
Definition: qwidget.h:119
QWidgetData * data
Definition: qwidget.h:815

◆ windowIcon()

QIcon QWidget::windowIcon ( ) const

◆ windowIconText()

QString QWidget::windowIconText ( ) const

◆ windowModality()

Qt::WindowModality QWidget::windowModality ( ) const

◆ windowOpacity()

qreal QWidget::windowOpacity ( ) const

◆ windowRole()

QString QWidget::windowRole ( ) const

Returns the window's role, or an empty string.

See also
windowIcon, windowTitle

Definition at line 6483 of file qwidget.cpp.

6484 {
6485  Q_D(const QWidget);
6486  return (d->extra && d->extra->topextra) ? d->extra->topextra->role : QString();
6487 }
double d
Definition: qnumeric_p.h:62
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define Q_D(Class)
Definition: qglobal.h:2482

◆ windowState()

Qt::WindowStates QWidget::windowState ( ) const

Returns the current window state.

The window state is a OR'ed combination of Qt::WindowState: Qt::WindowMinimized, Qt::WindowMaximized, Qt::WindowFullScreen, and Qt::WindowActive.

See also
Qt::WindowState setWindowState()

Definition at line 3086 of file qwidget.cpp.

Referenced by QSizeGripPrivate::_q_showIfNotHidden(), activateWindow(), QDecoration::buildSysMenu(), QMdiSubWindow::changeEvent(), QMdiSubWindowPrivate::ensureWindowState(), QDialog::event(), QMainWindow::event(), QMeeGoGraphicsSystemSwitchHandler::eventFilter(), QWorkspaceChild::eventFilter(), getNamedAttribute(), QApplicationPrivate::globalEventProcessor(), QVistaHelper::mouseMoveEvent(), QVistaHelper::mousePressEvent(), QDecorationStyled::paint(), QDecorationDefault::paint(), QtWndProc(), QDecorationWindows::region(), QDecorationDefault::region(), QDecoration::regionClicked(), QDecoration::regionDoubleClicked(), QBBScreen::resizeWindows(), restoreGeometry(), saveGeometry(), QMdiSubWindowPrivate::setActive(), QWorkspace::setActiveWindow(), QDialog::setVisible(), setVisible(), QDialog::showEvent(), showFullScreen(), showMaximized(), QWorkspaceChild::showMaximized(), showMinimized(), QWorkspaceChild::showMinimized(), showNormal(), QWorkspaceChild::showNormal(), QWorkspaceTitleBarPrivate::titleBarState(), and QWorkspaceChild::updateMask().

3087 {
3088  return Qt::WindowStates(data->window_state);
3089 }
uint window_state
Definition: qwidget.h:120
QWidgetData * data
Definition: qwidget.h:815

◆ windowSurface()

QWindowSurface * QWidget::windowSurface ( ) const

Returns the QWindowSurface this widget will be drawn into.

This function is under development and subject to change.

Since
4.2

Definition at line 12819 of file qwidget.cpp.

Referenced by QWidgetBackingStore::beginPaint(), PvrEglScreenSurfaceFunctions::createNativeWindow(), QXcbWindow::handleExposeEvent(), QApplicationPrivate::isAlien(), QWidgetPrivate::paintSiblingsRecursive(), QWidgetBackingStore::QWidgetBackingStore(), setAttribute(), QDirectFbWindow::setGeometry(), setParent(), QMainWindow::setUnifiedTitleAndToolBarOnMac(), QDirectFBScreen::surfaceForWidget(), QWidgetBackingStore::sync(), QETWidget::translateRegionEvent(), visibleRegion(), QDirectFBScreen::windowForWidget(), and QWindowSurface::~QWindowSurface().

12820 {
12821  Q_D(const QWidget);
12822  QTLWExtra *extra = d->maybeTopData();
12823  if (extra && extra->windowSurface)
12824  return extra->windowSurface;
12825 
12826  QWidgetBackingStore *bs = d->maybeBackingStore();
12827 
12828 #ifdef Q_BACKINGSTORE_SUBSURFACES
12829  if (bs && bs->subSurfaces.isEmpty())
12830  return bs->windowSurface;
12831 
12832  if (!isTopLevel()) {
12833  const QWidget *w = parentWidget();
12834  while (w) {
12835  QTLWExtra *extra = w->d_func()->maybeTopData();
12836  if (extra && extra->windowSurface)
12837  return extra->windowSurface;
12838  if (w->isTopLevel())
12839  break;
12840  w = w->parentWidget();
12841  }
12842  }
12843 #endif // Q_BACKINGSTORE_SUBSURFACES
12844 
12845  return bs ? bs->windowSurface : 0;
12846 }
double d
Definition: qnumeric_p.h:62
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
QWindowSurface * windowSurface
QWindowSurface * windowSurface
Definition: qwidget_p.h:167
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_D(Class)
Definition: qglobal.h:2482
bool isTopLevel() const
Use isWindow() instead.
Definition: qwidget.h:942
if(void) toggleToolbarShown

◆ windowTitle()

QString QWidget::windowTitle ( ) const

◆ windowType()

Qt::WindowType QWidget::windowType ( ) const
inline

Returns the window type of this widget.

This is identical to windowFlags() & Qt::WindowType_Mask.

See also
windowFlags

Definition at line 937 of file qwidget.h.

Referenced by activateWindow(), QBBScreen::addWindow(), QApplicationPrivate::applyX11SpecificCommandLineArguments(), backgroundRole(), QCoreGraphicsPaintEngine::begin(), clearFocus(), QApplication::closeAllWindows(), QApplicationPrivate::closePopup(), QShortcutMap::correctWidgetContext(), create(), QWidgetPrivate::create_sys(), QGLGraphicsSystem::createWindowSurface(), QApplication::desktop(), destroy(), DllCanUnloadNow(), QApplicationPrivate::enterModal(), QMacStyle::event(), QApplication::event(), event(), QX11Data::findClientWindow(), findRealWindow(), findWindowThatShouldDisplayMenubar(), focusNextPrevChild(), QApplicationPrivate::focusNextPrevChild_helper(), QApplicationPrivate::globalEventProcessor(), handle_xdnd_position(), QWidgetPrivate::init(), isTransient(), keyPressEvent(), QAbstractScrollAreaPrivate::layoutChildren(), QApplicationPrivate::leaveModal(), make_win_eventUPP(), QX11Data::motifdndObtainData(), mousePressEvent(), QWindowsXPStyle::pixelMetric(), QWindowsStyle::pixelMetric(), QMacStyle::pixelMetric(), QWidgetPrivate::pointToRect(), previousInFocusChain(), q_createNativeChildrenAndSetParent(), qt_event_activate_timer_callbk(), qt_mac_grabScreenRect_10_3(), qt_mac_is_macdrawer(), qt_mac_is_macsheet(), qt_sizegrip_topLevelWidget(), qt_xdnd_send_leave(), QtWndProc(), QApplication::qwsProcessEvent(), QMdiAreaPrivate::resizeToMinimumTileSize(), setDisabled(), setFocus(), setParent(), QBBWindow::setScreen(), QApplication::setStyle(), setVisible(), QFocusFrame::setWidget(), QWidgetPrivate::setWinId(), QCoreFuriCuri::timerEvent(), QApplication::topLevelWidgets(), topLevelWidgets(), QETWidget::translateMouseEvent(), unstylable(), updateRedirectedToGraphicsProxyWidget(), QApplication::winFocus(), QApplication::x11ProcessEvent(), xdndEnable(), and xdndObtainData().

938 { return static_cast<Qt::WindowType>(int(data->window_flags & Qt::WindowType_Mask)); }
WindowType
Definition: qnamespace.h:270
Qt::WindowFlags window_flags
Definition: qwidget.h:119
QWidgetData * data
Definition: qwidget.h:815

◆ winEvent()

bool QWidget::winEvent ( MSG message,
long *  result 
)
protectedvirtual

This special event handler can be reimplemented in a subclass to receive native Windows events which are passed in the message parameter.

In your reimplementation of this function, if you want to stop the event being handled by Qt, return true and set result to the value that the window procedure should return. 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::winEventFilter()

Reimplemented in QETWidget, QWizard, QAxHostWidget, QSystemTrayIconSys, QSizeGrip, and QSystemTrayIconSys.

Definition at line 9941 of file qwidget.cpp.

Referenced by QSystemTrayIconSys::findTrayGeometry(), QVistaHelper::leftMargin(), setShown(), QSizeGrip::winEvent(), QSystemTrayIconSys::winEvent(), QAxHostWidget::winEvent(), QWizard::winEvent(), and QETWidget::winEvent().

9942 {
9943  Q_UNUSED(message);
9944  Q_UNUSED(result);
9945  return false;
9946 }
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ winId()

WId QWidget::winId ( ) const

Returns the window system identifier of the widget.

Portable in principle, but if you use it you are probably about to do something non-portable. Be careful.

If a widget is non-native (alien) and winId() is invoked on it, that widget will be provided a native handle.

On Mac OS X, the type returned depends on which framework Qt was linked against. If Qt is using Carbon, the {WId} is actually an HIViewRef. If Qt is using Cocoa, {WId} is a pointer to an NSView.

This value may change at run-time. An event with type QEvent::WinIdChange will be sent to the widget following a change in window system identifier.

See also
find()

Definition at line 2557 of file qwidget.cpp.

Referenced by QAxClientSite::activateObject(), QAxServerBase::ActiveXProc(), QWSDisplay::addProperty(), QSystemTrayIconSys::addToTray(), alert_widget(), axc_FilterProc(), QWSDisplay::convertSelection(), QEgl::createSurface(), QWSDisplay::destroyRegion(), QX11EmbedWidget::embedInto(), QAxScriptSite::EnableModeless(), QTraceWindowSurface::endPaint(), ShivaVGWindowSurfacePrivate::ensureContext(), QAxHostWidget::event(), QVistaHelper::eventFilter(), find_trans_colors(), QSystemTrayIconSys::findIconGeometry(), getDC(), QAxClientSite::GetIDsOfNames(), QWSDisplay::getProperty(), QAxScriptSite::GetWindow(), QAxClientSite::GetWindow(), QAxClientSite::GetWindowContext(), QWSDisplay::grabKeyboard(), QWSDisplay::grabMouse(), QAInterface::hiObject(), QMainWindowLayout::insertIntoMacToolbar(), make_widget_eventUPP(), menuItemEntry(), QX11Data::motifdndHandle(), QSizeGrip::mouseMoveEvent(), QSizeGrip::mousePressEvent(), QWSDisplay::moveRegion(), QWSDisplay::nameRegion(), QBBNativeInterface::nativeResourceForWidget(), QEgl::nativeWindow(), QSystemTrayIconSys::paintEvent(), QGLOverlayWidget::paintGL(), parseGeometry(), q_createNativeChildrenAndSetParent(), qax_winEventFilter(), qCanAllocColors(), qDeleteQGLContext(), QSystemTrayIconSys::QSystemTrayIconSys(), qt_mac_checkForNativeSizeGrip(), qt_mac_get_widget_rgn(), qt_mac_update_widget_position(), QAxClientSite::qt_metacall(), qt_tablet_init(), qt_tablet_init_wce(), qt_win_get_existing_directory(), qt_win_get_save_file_name(), qt_win_make_OFN(), qt_win_setup_PRINTDLGEX(), qt_wince_maximize(), qt_wince_unmaximize(), QMainWindowLayout::qtoolbarInHIToolbarHandler(), QtWndProc(), QX11EmbedContainer::QX11EmbedContainer(), QX11EmbedWidget::QX11EmbedWidget(), QXcbWindow::QXcbWindow(), releaseDC(), QWSDisplay::removeProperty(), QWSDisplay::repaintRegion(), QWSDisplay::requestFocus(), QAxHostWidget::resizeObject(), QAlphaWidget::run(), screenForDevice(), QWSDisplay::sendIMResponse(), QWSDisplay::sendIMUpdate(), QWSDisplay::setAltitude(), setDisabledStyle(), QVistaHelper::setDWMTitleBar(), QWSInputContext::setFocusWidget(), QWSDisplay::setOpacity(), QWSDisplay::setProperty(), QWSDisplay::setSelectionOwner(), QVistaHelper::setTitleBarIconAndCaptionVisible(), QGtkStylePrivate::setupGtkFileChooser(), setVisible(), QVistaHelper::setWindowPosHack(), QMessageBox::showEvent(), QSystemTrayIconSys::showMessage(), QAxClientSite::TranslateAccelerator(), QWSInputContext::translateIMQueryEvent(), QSystemTrayIconSys::trayMessage(), QWindowsVistaStylePrivate::treeViewHelper(), QWSInputContext::update(), QGLContextPrivate::updateFormatVersion(), QGLContext::updatePaintDevice(), QWSEmbedWidgetPrivate::updateWindow(), QWSDisplay::Data::waitForRegionAck(), QWSDisplay::Data::waitForRegionEvents(), QMenuBarPrivate::wceCreateMenuBar(), QX11EmbedWidget::x11Event(), and QX11EmbedWidget::~QX11EmbedWidget().

2558 {
2560 #ifdef ALIEN_DEBUG
2561  qDebug() << "QWidget::winId: creating native window for" << this;
2562 #endif
2563  QWidget *that = const_cast<QWidget*>(this);
2564 #ifndef Q_WS_QPA
2566 #endif
2567  that->d_func()->createWinId();
2568  return that->data->winid;
2569  }
2570  return data->winid;
2571 }
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
Q_CORE_EXPORT void qDebug(const char *,...)
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
QWidgetData * data
Definition: qwidget.h:815
WId internalWinId() const
Returns the window system identifier of the widget, or 0 if the widget is not created yet...
Definition: qwidget.h:244
void setAttribute(Qt::WidgetAttribute, bool on=true)
Sets the attribute attribute on this widget if on is true; otherwise clears the attribute.
Definition: qwidget.cpp:11087
void createWinId()
Definition: qwidget.cpp:2626
WId winid
Definition: qwidget.h:117

◆ x()

int QWidget::x ( ) const

Referenced by QAbstractScrollAreaPrivate::_q_hslide(), QWorkspacePrivate::_q_scrollBarChanged(), QCalendarWidgetPrivate::_q_yearClicked(), QAxClientSite::activateObject(), QWorkspace::addWindow(), QPushButtonPrivate::adjustedMenuPosition(), QWorkspace::arrangeIcons(), QMenuBarPrivate::calcActionRects(), QWorkspace::cascade(), QSplitter::closestLegalPosition(), QWidgetPrivate::createTLExtra(), QColumnViewPrivate::doLayout(), QTreeView::drawRow(), QX11EmbedWidget::embedInto(), QPlainTextEditPrivate::ensureCursorVisible(), QScrollArea::ensureVisible(), QAxHostWidget::event(), QWorkspace::eventFilter(), QWorkspacePrivate::insertIcon(), QMainWindowLayout::itemAt(), QTreeViewPrivate::itemDecorationAt(), QMenu::keyPressEvent(), QGraphicsView::mapFromScene(), QGraphicsView::mapToScene(), QGraphicsViewPrivate::mapToScene(), QStatusBarPrivate::messageRect(), move(), QVistaBackButton::paintEvent(), QTableView::paintEvent(), QWizardHeader::paintEvent(), QRollEffect::paintEvent(), QGLOverlayWidget::paintGL(), QWidgetPrivate::paintSiblingsRecursive(), parseGeometry(), QWorkspacePrivate::place(), QWorkspaceChild::QWorkspaceChild(), read_bool_env_var(), repaint(), QRubberBand::resize(), resize(), QScriptEdit::resizeEvent(), QColorPicker::resizeEvent(), QAxHostWidget::resizeObject(), QRollEffect::scroll(), QTableView::scrollTo(), QLineEdit::selectionStart(), setBaseSize(), QColorPicker::setCol(), QWSDisplay::setCursorPosition(), setDisabled(), QDockWidget::setFloating(), setSizeIncrement(), QWhatsThat::showEvent(), QComboBox::showPopup(), QMainWindowLayout::takeAt(), QTableView::timerEvent(), QTreeView::timerEvent(), update(), QMenuPrivate::updateActionRects(), QMenuBarPrivate::updateGeometries(), QWorkspacePrivate::updateWorkspace(), QTreeView::visualRect(), and windowInteractsWithPosition().

◆ x11Event()

bool QWidget::x11Event ( XEvent event)
protectedvirtual

This special event handler can be reimplemented in a subclass to receive native X11 events passed in the event parameter.

In your reimplementation of this function, if you want to stop Qt from handling the event, return true. If you return false, this native event is passed back to Qt, which translates it into a Qt event and sends it to the widget.

Note
Events are only delivered to this event handler if the widget is native.
Warning
This function is not portable.
See also
QApplication::x11EventFilter(), QWidget::winId()

Reimplemented in QGLOverlayWidget, QSystemTrayIconSys, QX11EmbedContainer, and QX11EmbedWidget.

Definition at line 9969 of file qwidget.cpp.

Referenced by setShown(), QX11EmbedWidget::x11Event(), QX11EmbedContainer::x11Event(), QSystemTrayIconSys::x11Event(), and QApplication::x11ProcessEvent().

9970 {
9971  return false;
9972 }

◆ x11Info()

const QX11Info & QWidget::x11Info ( ) const

Returns information about the configuration of the X display used to display the widget.

Warning
This function is only available on X11.

Definition at line 3009 of file qwidget_x11.cpp.

Referenced by QGLContextPrivate::bindTextureFromNativePixmap(), QEgl::createSurface(), QX11EmbedContainer::discardClient(), QX11EmbedContainer::embedClient(), QX11EmbedWidget::embedInto(), QX11EmbedWidget::event(), QX11EmbedContainer::event(), QX11EmbedWidget::eventFilter(), QX11EmbedContainer::eventFilter(), QRasterWindowSurface::flush(), QX11GLWindowSurface::grabWidget(), QX11WindowSurface::grabWidget(), QX11EmbedContainer::hideEvent(), QDesktopWidgetPrivate::init(), QSizeGrip::mousePressEvent(), QGLOverlayWidget::paintGL(), qCanAllocColors(), QRasterWindowSurface::QRasterWindowSurface(), qstring_to_xtp(), qt_change_net_wm_state(), qt_format_to_attrib_list(), QX11EmbedContainer::QX11EmbedContainer(), QX11EmbedWidget::QX11EmbedWidget(), QX11WindowSurface::QX11WindowSurface(), QX11EmbedContainerPrivate::rejectClient(), QX11EmbedContainer::resizeEvent(), QWhatsThisPrivate::say(), QX11WindowSurface::setGeometry(), QX11EmbedContainer::showEvent(), QNativeImage::systemFormat(), QApplication::x11ClientMessage(), QX11EmbedWidget::x11Event(), QX11EmbedContainer::x11Event(), QApplication::x11ProcessEvent(), QX11EmbedContainer::~QX11EmbedContainer(), and QX11EmbedWidget::~QX11EmbedWidget().

3010 {
3011  Q_D(const QWidget);
3012  return d->xinfo;
3013 }
double d
Definition: qnumeric_p.h:62
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_D(Class)
Definition: qglobal.h:2482

◆ x11PictureHandle()

Qt::HANDLE QWidget::x11PictureHandle ( ) const

Returns the X11 Picture handle of the widget for XRender support.

Use of this function is not portable. This function will return 0 if XRender support is not compiled into Qt, if the XRender extension is not supported on the X11 display, or if the handle could not be created.

Definition at line 3045 of file qwidget_x11.cpp.

Referenced by QX11PaintEngine::begin().

3046 {
3047 #ifndef QT_NO_XRENDER
3048  Q_D(const QWidget);
3050  (void)winId(); // enforce native window
3051  return d->picture;
3052 #else
3053  return 0;
3054 #endif // QT_NO_XRENDER
3055 }
double d
Definition: qnumeric_p.h:62
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_D(Class)
Definition: qglobal.h:2482
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
WId internalWinId() const
Returns the window system identifier of the widget, or 0 if the widget is not created yet...
Definition: qwidget.h:244
WId winId() const
Returns the window system identifier of the widget.
Definition: qwidget.cpp:2557

◆ y()

int QWidget::y ( ) const

Friends and Related Functions

◆ isWidgetOpaque

bool isWidgetOpaque ( const QWidget w)
friend

Definition at line 81 of file qwindowsurface_qws.cpp.

82 {
83  return w->d_func()->isOpaque && !w->testAttribute(Qt::WA_TranslucentBackground);
84 }
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041

◆ QApplication

friend class QApplication
friend

Definition at line 743 of file qwidget.h.

◆ QApplicationPrivate

friend class QApplicationPrivate
friend

Definition at line 744 of file qwidget.h.

◆ QBackingStoreDevice

friend class QBackingStoreDevice
friend

Definition at line 741 of file qwidget.h.

◆ QBaseApplication

friend class QBaseApplication
friend

Definition at line 745 of file qwidget.h.

◆ QCoreGraphicsPaintEnginePrivate

Definition at line 774 of file qwidget.h.

◆ QDecoration

friend class QDecoration
friend

Definition at line 788 of file qwidget.h.

◆ QETWidget

friend class QETWidget
friend

Definition at line 751 of file qwidget.h.

◆ QFontInfo

friend class QFontInfo
friend

Definition at line 750 of file qwidget.h.

◆ QFontMetrics

friend class QFontMetrics
friend

Definition at line 749 of file qwidget.h.

Referenced by QMenu::initStyleOption(), and QHeaderView::sectionSizeFromContents().

◆ QGestureManager

friend class QGestureManager
friend

Definition at line 768 of file qwidget.h.

◆ QGLContext

friend class QGLContext
friend

Definition at line 755 of file qwidget.h.

◆ QGLWidget

friend class QGLWidget
friend

Definition at line 756 of file qwidget.h.

◆ QGLWidgetPrivate

friend class QGLWidgetPrivate
friend

Definition at line 793 of file qwidget.h.

◆ QGLWindowSurface

friend class QGLWindowSurface
friend

Definition at line 757 of file qwidget.h.

◆ QGraphicsProxyWidget

friend class QGraphicsProxyWidget
friend

Definition at line 763 of file qwidget.h.

◆ QGraphicsProxyWidgetPrivate

Definition at line 764 of file qwidget.h.

◆ QLayout

friend class QLayout
friend

Definition at line 752 of file qwidget.h.

◆ QPainter

friend class QPainter
friend

Definition at line 746 of file qwidget.h.

◆ QPainterPrivate

friend class QPainterPrivate
friend

Definition at line 747 of file qwidget.h.

◆ QPixmap

friend class QPixmap
friend

◆ QRasterWindowSurface

friend class QRasterWindowSurface
friend

Definition at line 781 of file qwidget.h.

◆ QScreen

friend class QScreen
friend

Definition at line 790 of file qwidget.h.

◆ QShortcutMap

friend class QShortcutMap
friend

Definition at line 761 of file qwidget.h.

◆ QShortcutPrivate

friend class QShortcutPrivate
friend

Definition at line 760 of file qwidget.h.

◆ QStyleSheetStyle

friend class QStyleSheetStyle
friend

Definition at line 765 of file qwidget.h.

Referenced by QWidgetPrivate::inheritStyle(), setStyle(), and setStyleSheet().

◆ qt_event_request_window_change

void qt_event_request_window_change ( QWidget widget)
friend

Definition at line 858 of file qapplication_mac.mm.

859 {
860  if (!widget)
861  return;
862 
863  // Post a kEventQtRequestWindowChange event. This event is semi-public,
864  // don't remove this line!
866 
867  // Post update request on gl widgets unconditionally.
868  if (qt_widget_private(widget)->isGLWidget == true) {
870  return;
871  }
872 
875 }
static void qt_mac_update_intersected_gl_widgets(QWidget *widget)
friend Q_GUI_EXPORT QWidgetPrivate * qt_widget_private(QWidget *widget)
Definition: qwidget.cpp:12920
static void qt_post_window_change_event(QWidget *widget)
friend void qt_event_request_window_change(QWidget *widget)
static void qt_mac_update_child_gl_widgets(QWidget *widget)

◆ qt_mac_is_metal

bool qt_mac_is_metal ( const QWidget w)
friend

Definition at line 490 of file qmacstyle_mac.mm.

491 {
492  for (; w; w = w->parentWidget()) {
494  return true;
495  if (w->isWindow() && w->testAttribute(Qt::WA_WState_Created)) { // If not created will fall through to the opaque check and be fine anyway.
497  }
498  if (w->d_func()->isOpaque)
499  break;
500  }
501  return false;
502 }
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
bool isWindow() const
Returns true if the widget is an independent window, otherwise returns false.
Definition: qwidget.h:945
friend OSWindowRef qt_mac_window_for(const QWidget *w)
Definition: qwidget_mac.mm:484
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
bool macWindowIsTextured(void *window)

◆ qt_mac_nativeview_for

OSViewRef qt_mac_nativeview_for ( const QWidget w)
friend

Definition at line 419 of file qwidget_mac.mm.

420 {
421  return reinterpret_cast<OSViewRef>(w->internalWinId());
422 }
WId internalWinId() const
Returns the window system identifier of the widget, or 0 if the widget is not created yet...
Definition: qwidget.h:244
HIViewRef OSViewRef

◆ qt_mac_posInWindow

QPoint qt_mac_posInWindow ( const QWidget w)
friend

Definition at line 380 of file qwidget_mac.mm.

381 {
382  QPoint ret = w->data->wrect.topLeft();
383  while(w && !w->isWindow()) {
384  ret += w->pos();
385  w = w->parentWidget();
386  }
387  return ret;
388 }
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
bool isWindow() const
Returns true if the widget is an independent window, otherwise returns false.
Definition: qwidget.h:945
QWidgetData * data
Definition: qwidget.h:815
QRect wrect
Definition: qwidget.h:145
QPoint pos
the position of the widget within its parent widget
Definition: qwidget.h:163
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
QPoint topLeft() const
Returns the position of the rectangle&#39;s top-left corner.
Definition: qrect.h:288

◆ qt_mac_sendMacEventToWidget

bool qt_mac_sendMacEventToWidget ( QWidget widget,
EventRef  ref 
)
friend

Definition at line 448 of file qwidget_mac.mm.

449 {
450  return widget->macEvent(0, ref);
451 }
virtual bool macEvent(EventHandlerCallRef, EventRef)
This special event handler can be reimplemented in a subclass to receive native Macintosh events...
Definition: qwidget.cpp:9918

◆ qt_mac_window_for

OSWindowRef qt_mac_window_for ( const QWidget w)
friend

Definition at line 484 of file qwidget_mac.mm.

Referenced by clearMask(), QToolBar::event(), QMenuPrivate::hideMenu(), QComboBox::hidePopup(), QRubberBand::QRubberBand(), and QTipLabel::timerEvent().

485 {
486  if (OSViewRef hiview = qt_mac_effectiveview_for(w)) {
488  if (window)
489  return window;
490 
491  if (qt_isGenuineQWidget(hiview)) {
492  // This is a workaround for NSToolbar. When a widget is hidden
493  // by clicking the toolbar button, Cocoa reparents the widgets
494  // to another window (but Qt doesn't know about it).
495  // When we start showing them, it reparents back,
496  // but at this point it's window is nil, but the window it's being brought
497  // into (the Qt one) is for sure created.
498  // This stops the hierarchy moving under our feet.
499  QWidget *toplevel = w->window();
500  if (toplevel != w) {
501  hiview = qt_mac_nativeview_for(toplevel);
502  if (OSWindowRef w = qt_mac_window_for(hiview))
503  return w;
504  }
505 
506  toplevel->d_func()->createWindow_sys();
507  // Reget the hiview since "create window" could potentially move the view (I guess).
508  hiview = qt_mac_nativeview_for(toplevel);
509  return qt_mac_window_for(hiview);
510  }
511  }
512  return 0;
513 }
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
friend OSWindowRef qt_mac_window_for(const QWidget *w)
Definition: qwidget_mac.mm:484
static bool qt_isGenuineQWidget(OSViewRef ref)
Definition: qwidget_mac.mm:464
WindowRef OSWindowRef
friend OSViewRef qt_mac_nativeview_for(const QWidget *w)
Definition: qwidget_mac.mm:419
QWidget * window() const
Returns the window for this widget, i.e.
Definition: qwidget.cpp:4492
HIViewRef OSViewRef
Q_GUI_EXPORT OSViewRef qt_mac_effectiveview_for(const QWidget *w)
Definition: qwidget_mac.mm:424

◆ qt_net_remove_user_time

void qt_net_remove_user_time ( QWidget tlw)
friend

Definition at line 1508 of file qapplication_x11.cpp.

1509 {
1510  Q_ASSERT(tlw);
1511  QTLWExtra *extra = tlw->d_func()->maybeTopData();
1512  if (extra && extra->userTimeWindow) {
1513  Q_ASSERT(tlw->internalWinId());
1514  XDeleteProperty(X11->display, tlw->internalWinId(), ATOM(_NET_WM_USER_TIME_WINDOW));
1515  XDestroyWindow(X11->display, extra->userTimeWindow);
1516  extra->userTimeWindow = 0;
1517  }
1518 }
WId userTimeWindow
Definition: qwidget_p.h:199
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define X11
Definition: qt_x11_p.h:724
#define ATOM(x)
Definition: qt_x11_p.h:723
WId internalWinId() const
Returns the window system identifier of the widget, or 0 if the widget is not created yet...
Definition: qwidget.h:244

◆ qt_net_update_user_time

void qt_net_update_user_time ( QWidget tlw,
unsigned long  timestamp 
)
friend

Definition at line 1520 of file qapplication_x11.cpp.

1521 {
1522  Q_ASSERT(tlw);
1523  Q_ASSERT(tlw->isWindow());
1525  QTLWExtra *extra = tlw->d_func()->topData();
1526  WId wid = tlw->internalWinId();
1527  const bool isSupportedByWM = X11->isSupportedByWM(ATOM(_NET_WM_USER_TIME_WINDOW));
1528  if (extra->userTimeWindow || isSupportedByWM) {
1529  if (!extra->userTimeWindow) {
1530  extra->userTimeWindow = XCreateSimpleWindow(X11->display,
1531  tlw->internalWinId(),
1532  -1, -1, 1, 1, 0, 0, 0);
1533  wid = extra->userTimeWindow;
1534  XChangeProperty(X11->display, tlw->internalWinId(), ATOM(_NET_WM_USER_TIME_WINDOW),
1535  XA_WINDOW, 32, PropModeReplace,
1536  (unsigned char *)&wid, 1);
1537  XDeleteProperty(X11->display, tlw->internalWinId(), ATOM(_NET_WM_USER_TIME));
1538  } else if (!isSupportedByWM) {
1539  // WM no longer supports it, then we should remove the
1540  // _NET_WM_USER_TIME_WINDOW atom.
1542  } else {
1543  wid = extra->userTimeWindow;
1544  }
1545  }
1546  XChangeProperty(X11->display, wid, ATOM(_NET_WM_USER_TIME),
1547  XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &timestamp, 1);
1548 }
friend void qt_net_remove_user_time(QWidget *tlw)
unsigned long WId
Definition: qwindowdefs.h:119
bool isWindow() const
Returns true if the widget is an independent window, otherwise returns false.
Definition: qwidget.h:945
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define X11
Definition: qt_x11_p.h:724
#define ATOM(x)
Definition: qt_x11_p.h:723
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
WId internalWinId() const
Returns the window system identifier of the widget, or 0 if the widget is not created yet...
Definition: qwidget.h:244

◆ qt_qwidget_data

Q_GUI_EXPORT QWidgetData* qt_qwidget_data ( QWidget widget)
friend

Definition at line 12915 of file qwidget.cpp.

12916 {
12917  return widget->data;
12918 }
QWidgetData * data
Definition: qwidget.h:815

◆ qt_set_winid_on_widget

void qt_set_winid_on_widget ( QWidget w,
Qt::HANDLE  id 
)
friend

Definition at line 325 of file qegl_x11.cpp.

326 {
327  w->create(id);
328 }
void create(WId=0, bool initializeWindow=true, bool destroyOldWindow=true)
Creates a new widget window if window is 0, otherwise sets the widget&#39;s window to window...
Definition: qwidget.cpp:1454

◆ qt_widget_private

Q_GUI_EXPORT QWidgetPrivate* qt_widget_private ( QWidget widget)
friend

◆ QUnifiedToolbarSurface

friend class QUnifiedToolbarSurface
friend

Definition at line 782 of file qwidget.h.

Referenced by QMainWindow::setUnifiedTitleAndToolBarOnMac().

◆ QVNCScreen

friend class QVNCScreen
friend

Definition at line 791 of file qwidget.h.

◆ QWidgetBackingStore

friend class QWidgetBackingStore
friend

Definition at line 742 of file qwidget.h.

◆ QWidgetEffectSourcePrivate

Definition at line 771 of file qwidget.h.

Referenced by setGraphicsEffect().

◆ QWidgetExceptionCleaner

friend struct QWidgetExceptionCleaner
friend

Definition at line 766 of file qwidget.h.

◆ QWidgetItem

friend class QWidgetItem
friend

Definition at line 753 of file qwidget.h.

◆ QWidgetItemV2

friend class QWidgetItemV2
friend

Definition at line 754 of file qwidget.h.

◆ QWidgetList()

QWidgetList
related

Synonym for QList<QWidget *>.

◆ QWin32PaintEngine

friend class QWin32PaintEngine
friend

Definition at line 759 of file qwidget.h.

◆ QWindowSurface

friend class QWindowSurface
friend

Definition at line 762 of file qwidget.h.

◆ QWinNativePanGestureRecognizer

Definition at line 769 of file qwidget.h.

◆ QWSBackingStore

friend class QWSBackingStore
friend

Definition at line 785 of file qwidget.h.

◆ QWSManager

friend class QWSManager
friend

Definition at line 786 of file qwidget.h.

Referenced by QETWidget::repaintDecoration(), and QETWidget::updateRegion().

◆ QWSManagerPrivate

friend class QWSManagerPrivate
friend

Definition at line 787 of file qwidget.h.

◆ QWSWindowSurface

friend class QWSWindowSurface
friend

Definition at line 789 of file qwidget.h.

◆ QX11PaintEngine

friend class QX11PaintEngine
friend

Definition at line 758 of file qwidget.h.

◆ WId()

WId
related

Platform dependent window identifier.

Referenced by QMacNativeWidget::QMacNativeWidget(), and QMacCocoaViewContainer::setCocoaView().

Properties

◆ acceptDrops

bool QWidget::acceptDrops
private

whether drop events are enabled for this widget

Setting this property to true announces to the system that this widget may be able to accept drop events.

If the widget is the desktop (windowType() == Qt::Desktop), this may fail if another application is using the desktop; you can call acceptDrops() to test if this occurs.

Warning
Do not modify this property in a drag and drop event handler.

By default, this property is false.

See also
{Drag and Drop}

Definition at line 197 of file qwidget.h.

Referenced by acceptsDrop(), QGraphicsProxyWidget::dragMoveEvent(), QIconModeViewBase::filterStartDrag(), findRealWindow(), handle_xdnd_position(), QX11Data::motifdndHandle(), QApplication::notify(), qt_xdnd_send_leave(), and xdndObtainData().

◆ accessibleDescription

QString QWidget::accessibleDescription
private

the widget's description as seen by assistive technologies

By default, this property contains an empty string.

See also
QAccessibleInterface::text()

Definition at line 214 of file qwidget.h.

Referenced by QAccessibleWidget::text().

◆ accessibleName

QString QWidget::accessibleName
private

the widget's name as seen by assistive technologies

This property is used by accessible clients to identify, find, or announce the widget for accessible clients.

By default, this property contains an empty string.

See also
QAccessibleInterface::text()

Definition at line 213 of file qwidget.h.

Referenced by QAccessibleButton::text(), QAccessibleWidget::text(), QAccessibleDisplay::text(), and QAccessibleDial::text().

◆ autoFillBackground

bool QWidget::autoFillBackground
private

whether the widget background is filled automatically

Since
4.1

If enabled, this property will cause Qt to fill the background of the widget before invoking the paint event. The color used is defined by the QPalette::Window color role from the widget's palette.

In addition, Windows are always filled with QPalette::Window, unless the WA_OpaquePaintEvent or WA_NoSystemBackground attributes are set.

This property cannot be turned off (i.e., set to false) if a widget's parent has a static gradient for its background.

Warning
Use this property with caution in conjunction with Qt Style Sheets. When a widget has a style sheet with a valid background or a border-image, this property is automatically disabled.

By default, this property is false.

See also
Qt::WA_OpaquePaintEvent, Qt::WA_NoSystemBackground, {QWidget::Transparency and Double Buffering}{Transparency and Double Buffering}

Definition at line 218 of file qwidget.h.

Referenced by make_widget_eventUPP(), QStyleSheetStyle::polish(), and QDirectFBWindowSurface::updateIsOpaque().

◆ baseSize

QSize QWidget::baseSize
private

the base size of the widget

The base size is used to calculate a proper widget size if the widget defines sizeIncrement().

By default, for a newly-created widget, this property contains a size with zero width and height.

See also
setSizeIncrement()

Definition at line 179 of file qwidget.h.

◆ childrenRect

QRect QWidget::childrenRect
private

the bounding rectangle of the widget's children

Hidden children are excluded.

By default, for a widget with no children, this property contains a rectangle with zero width and height located at the origin.

See also
childrenRegion() geometry()

Definition at line 169 of file qwidget.h.

Referenced by QMdiAreaPrivate::updateScrollBars().

◆ childrenRegion

QRegion QWidget::childrenRegion
private

the combined region occupied by the widget's children

Hidden children are excluded.

By default, for a widget with no children, this property contains an empty region.

See also
childrenRect() geometry() mask()

Definition at line 170 of file qwidget.h.

◆ contextMenuPolicy

Qt::ContextMenuPolicy QWidget::contextMenuPolicy
private

how the widget shows a context menu

The default value of this property is Qt::DefaultContextMenu, which means the contextMenuEvent() handler is called. Other values are Qt::NoContextMenu, Qt::PreventContextMenu, Qt::ActionsContextMenu, and Qt::CustomContextMenu. With Qt::CustomContextMenu, the signal customContextMenuRequested() is emitted.

See also
contextMenuEvent(), customContextMenuRequested(), actions()

Definition at line 189 of file qwidget.h.

Referenced by QtWndProc().

◆ cursor

QCursor QWidget::cursor
private

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:

If no cursor has been set, or after a call to unsetCursor(), the parent's cursor is used.

By default, this property contains a cursor with the Qt::ArrowCursor shape.

Some underlying window implementations will reset the cursor if it leaves a widget even if the mouse is grabbed. If you want to have a cursor set for all widgets, even when outside the window, consider QApplication::setOverrideCursor().

See also
QApplication::setOverrideCursor()

Definition at line 183 of file qwidget.h.

Referenced by QTextBrowserPrivate::_q_highlightLink(), QGraphicsViewPrivate::_q_setViewportCursor(), QApplicationPrivate::dispatchEnterLeave(), QWidgetResizeHandler::doResize(), effectiveState(), QWidgetResizeHandler::eventFilter(), QWidgetResizeHandler::keyPressEvent(), parseGeometry(), QGuiEventDispatcherWin32::processEvents(), qt_grab_cursor(), qt_mac_setMouseGrabCursor(), qt_mac_updateCursorWithWidgetUnderMouse(), qt_qpa_set_cursor(), qt_win_set_cursor(), qt_x11_enforce_cursor(), QDeclarativeTextInputPrivate::sendMouseEventToInputContext(), QGraphicsProxyWidgetPrivate::setWidget_helper(), QETWidget::translateMouseEvent(), and unsetLayoutDirection().

◆ data

QWidgetData* QWidget::data
private

Definition at line 815 of file qwidget.h.

Referenced by QScriptBreakpointsWidgetPrivate::_q_onNewBreakpointRequest(), QWidgetBackingStore::addDirtyWidget(), QWidgetPrivate::childAtRecursiveHelper(), QSidebar::clicked(), QWidgetPrivate::clipToEffectiveMask(), QWidgetPrivate::close_helper(), QApplication::closeAllWindows(), contentsRect(), create(), QApplicationPrivate::dispatchEnterLeave(), do_size_hints(), QAbstractItemViewPrivate::editor(), QX11EmbedContainer::embedClient(), event(), QSystemTrayIconSys::findIconGeometry(), findRealWindow(), QWidgetPrivate::frameStrut(), functor(), getNetWmState(), QSystemTrayIconSys::getSysTrayVisualInfo(), QX11EmbedContainer::hideEvent(), QWidgetPrivate::inheritStyle(), QWidgetPrivate::init(), QWidgetPrivate::isAboutToShow(), QWidgetPrivate::isBackgroundInherited(), QApplicationPrivate::isBlockedByModal(), isFullScreen(), isMaximized(), isMinimized(), QWidgetPrivate::isOverlapped(), isServerProcess(), QListWidget::items(), QTableWidget::items(), QTextBrowser::loadResource(), make_widget_eventUPP(), make_win_eventUPP(), mapFromParent(), mapToParent(), move(), overrideWindowFlags(), overrideWindowState(), QWidgetPrivate::paintSiblingsRecursive(), QWidgetPrivate::pointToRect(), QWidgetPrivate::propagatePaletteChange(), q_createNativeChildrenAndSetParent(), qt_cleanup(), qt_grab_cursor(), qt_mac_posInWindow(), qt_mac_update_widget_position(), qt_qwidget_data(), QX11EmbedWidget::QX11EmbedWidget(), repaint(), resize(), QWidgetPrivate::resolveFont(), QWidgetPrivate::resolvePalette(), QHeaderView::restoreState(), QSplitter::saveState(), QFileDialog::saveState(), QHeaderView::saveState(), QMainWindow::saveState(), QWidgetPrivate::scroll_sys(), QWidgetPrivate::scrollChildren(), QWidgetPrivate::sendPendingMoveAndResizeEvents(), QApplicationPrivate::sendSyntheticEnterLeave(), sendXEmbedMessage(), setAttribute(), setContentsMargins(), setContextMenuPolicy(), QScriptDebuggerCodeWidget::setCurrentScript(), setDisabled(), setFocusPolicy(), setForegroundRole(), setGeometry(), setMask(), setMinimumSize(), QWidgetPrivate::setPalette_helper(), setVisible(), setWindowFlags(), setWindowModality(), QWidgetPrivate::setWinId(), QWidgetPrivate::show_helper(), QSidebar::showContextMenu(), QX11EmbedContainer::showEvent(), QAbstractItemView::startDrag(), QWidgetPrivate::subtractOpaqueSiblings(), QWidgetBackingStore::topLevelRect(), update(), QAbstractItemViewPrivate::updateEditorData(), QWidgetPrivate::updateFont(), QStyleSheetStyle::updateStyleSheetFont(), windowState(), winId(), QApplication::x11ProcessEvent(), QX11Data::xdndHandleDrop(), QX11Data::xdndHandleEnter(), QX11Data::xdndHandleSelectionRequest(), and QX11Data::xdndMimeConvertToFormat().

◆ enabled

QWidget::enabled
private

whether the widget is enabled

In general an enabled widget handles keyboard and mouse events; a disabled widget does not. An exception is made with QAbstractButton.

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 use the changeEvent() with type QEvent::EnabledChange.

Disabling a widget implicitly disables all its children. Enabling respectively enables all child widgets unless they have been explicitly disabled.

By default, this property is true.

See also
isEnabledTo(), QKeyEvent, QMouseEvent, changeEvent()

Definition at line 157 of file qwidget.h.

Referenced by QTreeView::drawRow(), QScriptEdit::extraAreaMouseEvent(), QScriptEdit::extraAreaPaintEvent(), QListView::paintEvent(), QPlainTextEdit::setCenterOnScroll(), QMainWindow::setDockNestingEnabled(), QMdiArea::setDocumentMode(), QTabBar::setDocumentMode(), QTabBar::setExpanding(), QDialog::setSizeGripEnabled(), and QTabBar::setTabEnabled().

◆ focus

QWidget::focus
private

whether this widget (or its focus proxy) has the keyboard input focus

By default, this property is false.

Note
Obtaining the value of this property for a widget is effectively equivalent to checking whether QApplication::focusWidget() refers to the widget.
See also
setFocus(), clearFocus(), setFocusPolicy(), QApplication::focusWidget()

Definition at line 188 of file qwidget.h.

Referenced by QWorkspacePrivate::activateWindow(), QAxHostWidget::focusInEvent(), QWorkspacePrivate::hideChild(), QWorkspacePrivate::minimizeWindow(), and QListView::paintEvent().

◆ focusPolicy

Qt::FocusPolicy QWidget::focusPolicy
private

the way the widget accepts keyboard focus

The policy is Qt::TabFocus if the widget accepts keyboard focus by tabbing, Qt::ClickFocus if the widget accepts focus by clicking, Qt::StrongFocus if it accepts both, and Qt::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(Qt::StrongFocus).

If the widget has a focus proxy, then the focus policy will be propagated to it.

See also
focusInEvent(), focusOutEvent(), keyPressEvent(), keyReleaseEvent(), enabled

Definition at line 187 of file qwidget.h.

Referenced by QGroupBoxPrivate::_q_fixFocus(), QAccessibleToolButton::actionCount(), QAxServerBase::ActiveXProc(), QLabel::event(), QGraphicsProxyWidgetPrivate::findFocusChild(), QApplicationPrivate::focusNextPrevChild_helper(), QWidgetPrivate::frameStrut(), QX11EmbedWidgetPrivate::getFocusWidget(), QAxServerBase::internalActivate(), iWantTheFocus(), QtWndProc(), QApplication::qwsProcessEvent(), QMdiSubWindowPrivate::restoreFocus(), QWorkspaceChild::setActive(), QMenuPrivate::setCurrentAction(), QMdiSubWindowPrivate::setFocusWidget(), setTabOrder(), QDialog::setVisible(), QApplicationPrivate::shouldSetFocus(), QAccessibleWidget::state(), QAccessibleTabBar::state(), and QAxServerBase::TranslateAcceleratorW().

◆ font

const QFont & QWidget::font
inlineprivate

the font currently set for the widget

This property describes the widget's requested font. The font is used by the widget's style when rendering standard components, and is available as a means to ensure that custom widgets can maintain consistency with the native platform's look and feel. It's common that different platforms, or different styles, define different fonts for an application.

When you assign a new font to a widget, the properties from this font are combined with the widget's default font to form the widget's final font. You can call fontInfo() to get a copy of the widget's final font. The final font is also used to initialize QPainter's font.

The default depends on the system environment. QApplication maintains a system/theme font which serves as a default for all widgets. There may also be special font defaults for certain types of widgets. You can also define default fonts for widgets yourself by passing a custom font and the name of a widget to QApplication::setFont(). Finally, the font is matched against Qt's font database to find the best match.

QWidget propagates explicit font properties from parent to child. If you change a specific property on a font and assign that font to a widget, that property will propagate to all the widget's children, overriding any system defaults for that property. Note that fonts by default don't propagate to windows (see isWindow()) unless the Qt::WA_WindowPropagation attribute is enabled.

QWidget's font propagation is similar to its palette propagation.

The current style, which is used to render the content of all standard Qt widgets, is free to choose to use the widget font, or in some cases, to ignore it (partially, or completely). In particular, certain styles like GTK style, Mac style, Windows XP, and Vista style, apply special modifications to the widget font to match the platform's native look and feel. Because of this, assigning properties to a widget's font is not guaranteed to change the appearance of the widget. Instead, you may choose to apply a styleSheet .

Note
If Qt Style Sheets are used on the same widget as setFont(), style sheets will take precedence if the settings conflict.
See also
fontInfo(), fontMetrics()

Definition at line 181 of file qwidget.h.

Referenced by QXIMInputContext::createICData(), QPainter::initFrom(), QWindowsVistaStyle::polish(), qt_aqua_get_known_size(), QStyleSheetStyle::setPalette(), QCleanlooksStyle::subControlRect(), QGtkStyle::subControlRect(), QWindowsVistaStyle::unpolish(), and QStyleSheetStyle::updateStyleSheetFont().

◆ frameGeometry

QRect QWidget::frameGeometry
private

◆ frameSize

QSize QWidget::frameSize
private

the size of the widget including any window frame

By default, this property contains a value that depends on the user's platform and screen geometry.

Definition at line 164 of file qwidget.h.

◆ fullScreen

QWidget::fullScreen
private

whether the widget is shown in full screen mode

A widget in full screen mode occupies the whole screen area and does not display window decorations, such as a title bar.

By default, this property is false.

See also
windowState(), minimized, maximized

Definition at line 194 of file qwidget.h.

Referenced by restoreGeometry().

◆ geometry

const QRect & QWidget::geometry
inlineprivate

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

Warning
Calling setGeometry() inside resizeEvent() or moveEvent() can lead to infinite recursion.

See the Window Geometry documentation for an overview of geometry issues with windows.

By default, this property contains a value that depends on the user's platform and screen geometry.

See also
frameGeometry(), rect(), move(), resize(), moveEvent(), resizeEvent(), minimumSize(), maximumSize()

Definition at line 158 of file qwidget.h.

Referenced by QDialog::adjustPosition(), QWidgetAnimator::animate(), QDockAreaLayoutInfo::apply(), QApplicationPrivate::applyX11SpecificCommandLineArguments(), QAccessibleWidget::childAt(), QAccessibleMainWindow::childAt(), do_size_hints(), dockedGeometry(), QBoxLayoutPrivate::effectiveMargins(), QGridLayoutPrivate::effectiveMargins(), QAlphaWidget::eventFilter(), find_child(), QGLWindowSurface::flush(), QWidgetPrivate::getOpaqueChildren(), QVNCIntegration::grabWindow(), QWorkspacePrivate::insertIcon(), isServerProcess(), QCoreGraphicsPaintEngine::macDisplayColorSpace(), make_win_eventUPP(), QWidgetResizeHandler::mouseMoveEvent(), QSizeGrip::mousePressEvent(), QVNCIntegration::moveToScreen(), QWindowSurface::offset(), QWSWindowSurface::painterOffset(), QWSMemorySurface::painterOffset(), QStatusBar::paintEvent(), parseGeometry(), QWorkspacePrivate::place(), QBBWindow::QBBWindow(), QCocoaWindow::QCocoaWindow(), QCocoaWindowSurface::QCocoaWindowSurface(), QPlaceHolderItem::QPlaceHolderItem(), qt_cleanup(), qt_mac_unregister_widget(), qt_show_system_menu(), qt_try_modal(), QAccessibleTabBar::rect(), QAccessibleDockWidget::rect(), QAccessibleTitleBar::rect(), QDecoration::regionAt(), QAlphaWidget::run(), QRollEffect::run(), QToolBarAreaLayout::saveState(), QRollEffect::scroll(), QWSWindowSurface::setClipRegion(), PvrEglWindowSurface::setDirectRegion(), setDisabled(), QWSWindowSurface::setGeometry(), QWSLocalMemSurface::setGeometry(), QStackedLayout::setStackingMode(), QBoxLayoutPrivate::setupGeom(), QGridLayoutPrivate::setupSpacings(), spacingHelper(), QMainWindowLayout::toggleToolBarsVisible(), QPlatformScreen::topLevelAt(), QETWidget::translateMouseEvent(), QGraphicsProxyWidgetPrivate::updateProxyGeometryFromWidget(), and QVGEGLWindowSurfacePrivate::windowSurfaceSize().

◆ height

int QWidget::height
inlineprivate

the height of the widget excluding any window frame

See the Window Geometry documentation for an overview of geometry issues with windows.

Note
Do not use this function to find the height of a screen on a multiple screen desktop. Read this note for details.

By default, this property contains a value that depends on the user's platform and screen geometry.

See also
geometry, width, size

Definition at line 167 of file qwidget.h.

Referenced by QPlainTextEditPrivate::_q_adjustScrollbars(), QPrintDialogPrivate::_q_collapseOrExpandDialog(), QTextEditPrivate::_q_ensureVisible(), QTextEditPrivate::_q_repaintContents(), QPlainTextEditPrivate::_q_repaintContents(), QAxServerBase::ActiveXProc(), QDialog::adjustPosition(), QWorkspaceChild::adjustToFullscreen(), QWidgetAnimator::animate(), QApplicationPrivate::applyX11SpecificCommandLineArguments(), QMacStylePrivate::aquaSizeConstrain(), QWorkspace::arrangeIcons(), QPainterPrivate::attachPainterPrivate(), QPlainTextEditControl::blockBoundingRect(), QGraphicsView::centerOn(), QAccessibleWidget::childAt(), QAccessibleComboBox::childAt(), QAccessibleMainWindow::childAt(), QWidgetPrivate::clipRect(), QLayout::closestAcceptableSize(), QSizeGripPrivate::corner(), QColumnViewPrivate::createColumn(), QXIMInputContext::createICData(), QEgl::createSurface(), distance(), QColumnViewPrivate::doLayout(), QWidgetResizeHandler::doResize(), drawTabBase(), dumpRecursive(), QGraphicsView::ensureVisible(), QMacWindowSurface::flush(), QGLWindowSurface::flush(), QRasterWindowSurface::flush(), QPixmap::grabWidget(), QPixmap::grabWindow(), QWorkspacePrivate::insertIcon(), make_widget_eventUPP(), QListModeViewBase::mapToViewport(), QWidgetResizeHandler::mouseMoveEvent(), QWorkspaceTitleBar::mouseMoveEvent(), QSizeGrip::mousePressEvent(), QColumnViewGrip::moveGrip(), QTreeViewPrivate::pageDown(), QTreeViewPrivate::pageUp(), QTableView::paintEvent(), parseGeometry(), QWorkspacePrivate::place(), QRasterWindowSurface::prepareBuffer(), QDirectFbWindow::QDirectFbWindow(), QOpenKODEWindow::QOpenKODEWindow(), QRollEffect::QRollEffect(), qt_aqua_guess_size(), QXcbWindow::QXcbWindow(), QXlibWindow::QXlibWindow(), QMdi::IconTiler::rearrange(), QAccessibleWidget::rect(), QAccessibleToolButton::rect(), QTextEditPrivate::relayoutDocument(), QColumnViewPreviewColumn::resizeEvent(), QHeaderViewPrivate::resizeSections(), QHeaderView::setOffsetToLastSection(), QTextBrowserPrivate::setSource(), QHeaderViewPrivate::setupSectionIndicator(), QMdiSubWindowPrivate::showButtonsInMenuBar(), QCompleterPrivate::showPopup(), QMacStyle::subElementRect(), QGLContext::updatePaintDevice(), QGraphicsViewPrivate::updateRect(), QGraphicsViewPrivate::updateRegion(), QFocusFramePrivate::updateSize(), QCommonListViewBase::updateVerticalScrollBar(), QScrollAreaPrivate::updateWidgetPosition(), and QWorkspacePrivate::updateWorkspace().

◆ inputMethodHints

Qt::InputMethodHints QWidget::inputMethodHints
private

What input method specific hints the widget has.

This is only relevant for input widgets. It is used by the input method to retrieve hints as to how the input method should operate. For example, if the Qt::ImhFormattedNumbersOnly flag is set, the input method may change its visual components to reflect that only numbers can be entered.

Note
The flags are only hints, so the particular input method implementation is free to ignore them. If you want to be sure that a certain type of characters are entered, you should also set a QValidator on the widget.

The default value is Qt::ImhNone.

Since
4.6
See also
inputMethodQuery(), QInputContext

Definition at line 224 of file qwidget.h.

Referenced by QMacInputContext::globalEventProcessor(), QBBInputContext::setFocusWidget(), QXIMInputContext::setFocusWidget(), QBBAbstractVirtualKeyboard::setInputHintsFromWidget(), QWinInputContext::updateImeStatus(), and QGraphicsViewPrivate::updateInputMethodSensitivity().

◆ isActiveWindow

bool QWidget::isActiveWindow
private

whether this widget's window is the active window

The active window is the window that contains the widget that has keyboard focus (The window may still have focus if it has no widgets or none of its widgets accepts keyboard focus).

When popup windows are visible, this property is true for both the active window and for the popup.

By default, this property is false.

See also
activateWindow(), QApplication::activeWindow()

Definition at line 186 of file qwidget.h.

Referenced by QApplication::alert(), alert_widget(), QMacStylePrivate::animatable(), QWindowsVistaStyle::drawComplexControl(), QWindowsXPStyle::drawComplexControl(), QApplication::event(), QStyledItemDelegate::eventFilter(), QItemDelegate::eventFilter(), QMacStylePrivate::eventFilter(), QApplicationPrivate::globalEventProcessor(), QStyleOption::init(), make_win_eventUPP(), QWizardAntiFlickerWidget::paintEvent(), previousInFocusChain(), qt_try_modal(), QApplication::setActiveWindow(), setFocus(), QAccessibleTabBar::state(), QApplication::syncX(), QMacStylePrivate::timerEvent(), QETWidget::translateMouseEvent(), QWorkspaceTitleBar::usesActiveColor(), and QApplication::x11ProcessEvent().

◆ layoutDirection

Qt::LayoutDirection QWidget::layoutDirection
private

the layout direction for this widget

By default, this property is set to Qt::LeftToRight.

When the layout direction is set on a widget, it will propagate to the widget's children, but not to a child that is a window and not to a child for which setLayoutDirection() has been explicitly called. Also, child widgets added after setLayoutDirection() has been called for the parent do not inherit the parent's layout direction.

This method no longer affects text layout direction since Qt 4.7.

See also
QApplication::layoutDirection

Definition at line 216 of file qwidget.h.

Referenced by QLayout::alignmentRect(), QFormLayoutPrivate::arrangeWidgets(), QMacStyle::drawControl(), QBoxLayoutPrivate::effectiveMargins(), QGridLayoutPrivate::effectiveMargins(), QStyleOption::init(), QMdi::RegularTiler::rearrange(), QMdi::SimpleCascader::rearrange(), QMdi::IconTiler::rearrange(), QGraphicsWidgetPrivate::resolveLayoutDirection(), QGraphicsProxyWidgetPrivate::setWidget_helper(), QCompleterPrivate::showPopup(), and QStyledItemDelegate::updateEditorGeometry().

◆ locale

QLocale QWidget::locale
private

the widget's locale

Since
4.3

As long as no special locale has been set, this is either the parent's locale or (if this widget is a top level widget), the default locale.

If the widget displays dates or numbers, these should be formatted using the widget's locale.

See also
QLocale QLocale::setDefault()

Definition at line 222 of file qwidget.h.

◆ maximized

QWidget::maximized
private

whether this widget is maximized

This property is only relevant for windows.

Note
Due to limitations on 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.

By default, this property is false.

See also
windowState(), showMaximized(), visible, show(), hide(), showNormal(), minimized

Definition at line 193 of file qwidget.h.

Referenced by restoreGeometry(), and setMinimumSize().

◆ maximumHeight

int QWidget::maximumHeight
inlineprivate

the widget's maximum height in pixels

This property corresponds to the height held by the maximumSize property.

By default, this property contains a value of 16777215.

Note
The definition of the QWIDGETSIZE_MAX macro limits the maximum size of widgets.
See also
maximumSize, maximumWidth

Definition at line 177 of file qwidget.h.

Referenced by QStatusBar::event(), and QStatusBar::reformat().

◆ maximumSize

QSize QWidget::maximumSize
private

◆ maximumWidth

int QWidget::maximumWidth
inlineprivate

the widget's maximum width in pixels

This property corresponds to the width held by the maximumSize property.

By default, this property contains a value of 16777215.

Note
The definition of the QWIDGETSIZE_MAX macro limits the maximum size of widgets.
See also
maximumSize, maximumHeight

Definition at line 176 of file qwidget.h.

◆ minimized

QWidget::minimized
private

whether this widget is minimized (iconified)

This property is only relevant for windows.

By default, this property is false.

See also
showMinimized(), visible, show(), hide(), showNormal(), maximized

Definition at line 192 of file qwidget.h.

◆ minimumHeight

int QWidget::minimumHeight
inlineprivate

the widget's minimum height in pixels

This property corresponds to the height held by the minimumSize property.

By default, this property has a value of 0.

See also
minimumSize, minimumWidth

Definition at line 175 of file qwidget.h.

Referenced by QWorkspaceChild::adjustToFullscreen().

◆ minimumSize

QSize QWidget::minimumSize
private

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.

The minimum size set by this function will override the minimum size defined by QLayout. In order to unset the minimum size, use a value of QSize(0, 0).

By default, this property contains a size with zero width and height.

See also
minimumWidth, minimumHeight, maximumSize, sizeIncrement

Definition at line 172 of file qwidget.h.

Referenced by QWorkspacePrivate::_q_updateActions(), QLayout::activate(), QApplicationPrivate::applyX11SpecificCommandLineArguments(), QTreeView::indexRowSizeHint(), QWorkspaceChild::minimumSizeHint(), QWidgetResizeHandler::mouseMoveEvent(), QWorkspacePrivate::normalizeWindow(), parseGeometry(), qSmartMaxSize(), qSmartMinSize(), QWorkspaceChild::QWorkspaceChild(), QToolBarAreaLayoutItem::realSizeHint(), QGraphicsProxyWidgetPrivate::setWidget_helper(), QTableView::sizeHintForColumn(), QTreeView::sizeHintForColumn(), QTableView::sizeHintForRow(), QAccessibleWidget::state(), and QWorkspace::tile().

◆ minimumSizeHint

QSize QWidget::minimumSizeHint
private

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 the minimum size hint unless minimumSize() is set or the size policy is set to QSizePolicy::Ignore. If minimumSize() is set, the minimum size hint will be ignored.

See also
QSize::isValid(), resize(), setMinimumSize(), sizePolicy()

Definition at line 196 of file qwidget.h.

Referenced by QWorkspaceChild::minimumSizeHint(), qSmartMaxSize(), qSmartMinSize(), QWorkspaceChild::QWorkspaceChild(), and QToolBarAreaLayoutItem::realSizeHint().

◆ minimumWidth

int QWidget::minimumWidth
inlineprivate

the widget's minimum width in pixels

This property corresponds to the width held by the minimumSize property.

By default, this property has a value of 0.

See also
minimumSize, minimumHeight

Definition at line 174 of file qwidget.h.

Referenced by QWorkspaceChild::adjustToFullscreen(), QColumnViewPrivate::createColumn(), menuBarHeightForWidth(), QColumnViewGrip::moveGrip(), QColumnViewPreviewColumn::resizeEvent(), and QColumnViewPreviewColumn::setPreviewWidget().

◆ modal

QWidget::modal
private

whether the widget is a modal widget

This property only makes sense for windows. A modal widget prevents widgets in all other windows from getting any input.

By default, this property is false.

See also
isWindow(), windowModality, QDialog

Definition at line 155 of file qwidget.h.

◆ mouseTracking

QWidget::mouseTracking
private

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

Definition at line 185 of file qwidget.h.

◆ normalGeometry

QRect QWidget::normalGeometry
private

the geometry of the widget as it will appear when shown as a normal (not maximized or full screen) top-level widget

For child widgets this property always holds an empty rectangle.

By default, this property contains an empty rectangle.

See also
QWidget::windowState(), QWidget::geometry

Definition at line 160 of file qwidget.h.

Referenced by make_win_eventUPP().

◆ palette

const QPalette & QWidget::palette
private

the widget's palette

This property describes the widget's palette. The palette is used by the widget's style when rendering standard components, and is available as a means to ensure that custom widgets can maintain consistency with the native platform's look and feel. It's common that different platforms, or different styles, have different palettes.

When you assign a new palette to a widget, the color roles from this palette are combined with the widget's default palette to form the widget's final palette. The palette entry for the widget's background role is used to fill the widget's background (see QWidget::autoFillBackground), and the foreground role initializes QPainter's pen.

The default depends on the system environment. QApplication maintains a system/theme palette which serves as a default for all widgets. There may also be special palette defaults for certain types of widgets (e.g., on Windows XP and Vista, all classes that derive from QMenuBar have a special default palette). You can also define default palettes for widgets yourself by passing a custom palette and the name of a widget to QApplication::setPalette(). Finally, the style always has the option of polishing the palette as it's assigned (see QStyle::polish()).

QWidget propagates explicit palette roles from parent to child. If you assign a brush or color to a specific role on a palette and assign that palette to a widget, that role will propagate to all the widget's children, overriding any system defaults for that role. Note that palettes by default don't propagate to windows (see isWindow()) unless the Qt::WA_WindowPropagation attribute is enabled.

QWidget's palette propagation is similar to its font propagation.

The current style, which is used to render the content of all standard Qt widgets, is free to choose colors and brushes from the widget palette, or in some cases, to ignore the palette (partially, or completely). In particular, certain styles like GTK style, Mac style, Windows XP, and Vista style, depend on third party APIs to render the content of widgets, and these styles typically do not follow the palette. Because of this, assigning roles to a widget's palette is not guaranteed to change the appearance of the widget. Instead, you may choose to apply a styleSheet . You can refer to our Knowledge Base article here for more information.

Warning
Do not use this function in conjunction with Qt Style Sheets. When using style sheets, the palette of a widget can be customized using the "color", "background-color", "selection-color", "selection-background-color" and "alternate-background-color".
See also
QApplication::palette(), QWidget::font()

Definition at line 180 of file qwidget.h.

Referenced by QEgl::createSurface(), QCommonStyle::drawControl(), QStyleOption::init(), QPainter::initFrom(), QAccessibleWidgetEx::invokeMethodEx(), make_widget_eventUPP(), QGraphicsView::paintEvent(), paintSep(), QMacStyle::polish(), QWhatsThat::QWhatsThat(), QStyleSheetStyle::setPalette(), QInputContext::standardFormat(), QDirectFBWindowSurface::updateIsOpaque(), QToolBoxPrivate::updateTabs(), QScriptDebuggerLocalsItemDelegate::validateInput(), and QScriptBreakpointsItemDelegate::validateInput().

◆ pos

QPoint QWidget::pos
private

the position of the widget within its parent widget

If the widget is a window, 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.

By default, this property contains a position that refers to the origin.

Warning
Calling move() or setGeometry() inside moveEvent() can lead to infinite recursion.

See the Window Geometry documentation for an overview of geometry issues with windows.

See also
frameGeometry, size x(), y()

Definition at line 163 of file qwidget.h.

Referenced by do_size_hints(), QGraphicsProxyWidgetPrivate::mapToReceiver(), QToolBarPrivate::mouseMoveEvent(), QApplication::notify(), qt_mac_posInWindow(), qt_x11_recreateWidget(), QTreeViewPrivate::renderTreeToPixmapForAnimation(), QWidgetPrivate::scroll_sys(), QWidgetPrivate::scrollChildren(), QApplicationPrivate::sendMouseEvent(), setDisabled(), and QGraphicsProxyWidgetPrivate::updateProxyGeometryFromWidget().

◆ rect

QRect QWidget::rect
inlineprivate

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 geometry issues with windows.

By default, this property contains a value that depends on the user's platform and screen geometry.

See also
size

Definition at line 168 of file qwidget.h.

Referenced by QPlainTextEditPrivate::_q_adjustScrollbars(), QPlainTextEditPrivate::append(), QTreeViewPrivate::beginAnimatedOperation(), QGLWindowSurface::buffer(), QGraphicsViewPrivate::centerView(), QAccessibleStackedWidget::childAt(), QDialog::contextMenuEvent(), QWidgetBackingStore::dirtyRegion(), do_size_hints(), QWidgetResizeHandler::doMove(), QWidgetResizeHandler::doResize(), QAbstractItemViewPrivate::draggablePaintPairs(), QListViewPrivate::draggablePaintPairs(), QWindowsVistaStyle::drawComplexControl(), QWindowsVistaStyle::drawControl(), QGtkStyle::drawControl(), QGraphicsScenePrivate::drawItemHelper(), QWindowsVistaStyle::drawPrimitive(), QWindowsXPStyle::drawPrimitive(), QAbstractItemViewPrivate::dropOn(), QPlainTextEditPrivate::ensureCursorVisible(), QWidgetResizeHandler::eventFilter(), QPlastiqueStyle::eventFilter(), QTreeViewPrivate::expandOrCollapseItemAtPos(), QAbstractItemViewPrivate::fetchMore(), QGraphicsView::fitInView(), flipPoint(), QGLWindowSurface::flush(), QRasterWindowSurface::flush(), QWidgetPrivate::frameStrut(), QWidgetPrivate::getOpaqueChildren(), QX11GLWindowSurface::grabWidget(), QX11WindowSurface::grabWidget(), QWindowSurface::grabWidget(), QPixmap::grabWidget(), handle_xdnd_position(), QListViewPrivate::horizontalScrollToValue(), QStyleOption::init(), QWSWindowSurface::invalidateBuffer(), QWidgetPrivate::isBackgroundInherited(), QAbstractScrollAreaPrivate::layoutChildren(), QWidgetBackingStore::markDirty(), QTest::mouseEvent(), QWidgetResizeHandler::mouseMoveEvent(), QWorkspaceTitleBar::mouseMoveEvent(), QAbstractButtonPrivate::moveFocus(), QPlainTextEditPrivate::pageUpDown(), QDecorationStyled::paint(), QDecorationDefault::paint(), QTextEditPrivate::paint(), QPlainTextEdit::paintEvent(), QTreeViewPrivate::prepareAnimatedOperation(), qt_grab_cursor(), qt_mac_update_widget_position(), QMdiAreaPrivate::rearrange(), QAccessibleAbstractSpinBox::rect(), QTreeViewPrivate::AnimatedOperation::rect(), QAccessibleTextEdit::rect(), QDecoration::region(), QWidgetBackingStore::removeDirtyWidget(), QGraphicsView::render(), QMdiAreaPrivate::resizeToMinimumTileSize(), QWidgetPrivate::screenGeometry(), QRuntimeGraphicsSystem::setGraphicsSystem(), QWidgetBackingStore::showYellowThing(), QCommonStyle::styleHint(), QDirectFBWindowSurface::surfaceForWidget(), QWidgetBackingStore::sync(), QDecorationStyled::titleBarHeight(), QXIMInputContext::update(), QGraphicsViewPrivate::updateLastCenterPoint(), QGraphicsView::updateScene(), QScrollAreaPrivate::updateWidgetPosition(), QListViewPrivate::verticalScrollToValue(), and QApplication::widgetAt().

◆ size

QSize QWidget::size
inlineprivate

the size of the widget excluding any window frame

If the widget is visible when it is being resized, it 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().

By default, this property contains a value that depends on the user's platform and screen geometry.

Warning
Calling resize() or setGeometry() inside resizeEvent() can lead to infinite recursion.
Note
Setting the size to QSize(0, 0) will cause the widget to not appear on screen. This also applies to windows.
See also
pos, geometry, minimumSize, maximumSize, resizeEvent(), adjustSize()

Definition at line 165 of file qwidget.h.

Referenced by QTextEditPrivate::_q_adjustScrollbars(), QLayout::activate(), QWidgetAnimator::animate(), QMdiAreaPrivate::appendChild(), QWindowSurface::buffer(), QWorkspace::cascade(), QAccessibleAbstractScrollArea::childAt(), QLayout::closestAcceptableSize(), QScrollArea::ensureWidgetVisible(), QGLWindowSurface::flush(), QSplitterLayoutStruct::getWidgetSize(), QTabBar::initStyleOption(), QDockAreaLayoutInfo::insertGap(), QListView::paintEvent(), PvrEglWindowSurface::PvrEglWindowSurface(), QBBWindow::QBBWindow(), QCocoaWindowSurface::QCocoaWindowSurface(), QDirectFbWindowSurface::QDirectFbWindowSurface(), QFbWindowSurface::QFbWindowSurface(), qt_mac_get_widget_rgn(), qt_mac_update_intersected_gl_widgets(), qt_mac_updateParentUnderAlienWidget(), QWorkspaceChild::QWorkspaceChild(), QAccessibleAbstractScrollArea::rect(), QAccessibleCalendarWidget::rect(), QColumnViewPreviewColumn::resizeEvent(), QWorkspaceChild::resizeEvent(), QMdiAreaPrivate::resizeToMinimumTileSize(), QAlphaWidget::run(), QGLWindowSurface::scroll(), QWidgetPrivate::scroll_sys(), QWidgetPrivate::scrollChildren(), QColumnView::scrollTo(), sendResizeEvents(), QLayout::setMenuBar(), QDeclarativeView::setRootObject(), QGraphicsProxyWidget::subWidgetRect(), QDirectFBWindowSurface::surfaceForWidget(), QDirectFBScreen::surfaceForWidget(), QGraphicsProxyWidgetPrivate::updateProxyGeometryFromWidget(), QScrollAreaPrivate::updateScrollBars(), QColumnViewPrivate::updateScrollbars(), QTreeViewPrivate::updateScrollBars(), QScrollAreaPrivate::updateWidgetPosition(), and QApplication::x11ProcessEvent().

◆ sizeHint

QSize QWidget::sizeHint
private

◆ sizeIncrement

QSize QWidget::sizeIncrement
private

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:

Note that while you can set the size increment for all widgets, it only affects windows.

By default, this property contains a size with zero width and height.

Warning
The size increment has no effect under Windows, and may be disregarded by the window manager on X11.
See also
size, minimumSize, maximumSize

Definition at line 178 of file qwidget.h.

◆ sizePolicy

QSizePolicy QWidget::sizePolicy
private

the default layout behavior of the widget

If there is a QLayout that manages this widget's children, the size policy specified by that layout is used. If there is no such QLayout, the result of this function is used.

The default policy is Preferred/Preferred, which means that the widget can be freely resized, but prefers to be the size sizeHint() returns. Button-like widgets set the size policy to specify that they may stretch horizontally, but are fixed vertically. The same applies to lineedit controls (such as QLineEdit, QSpinBox or an editable QComboBox) and other horizontally orientated widgets (such as QProgressBar). QToolButton's are normally square, so they allow growth in both directions. Widgets that support different directions (such as QSlider, QScrollBar or QHeader) specify stretching in the respective direction only. Widgets that can provide scroll bars (usually subclasses of QScrollArea) tend to specify that they can use additional space, and that they can make do with less than sizeHint().

See also
sizeHint() QLayout QSizePolicy updateGeometry()

Definition at line 171 of file qwidget.h.

Referenced by QAbstractScrollAreaScrollBarContainer::addWidget(), QLayoutItem::controlTypes(), QSplitterPrivate::doResize(), QSplitterPrivate::findWidget(), QSplitterLayoutStruct::getWidgetSize(), QBoxLayoutItem::hStretch(), QMacStyle::pixelMetric(), qSmartMaxSize(), qSmartMinSize(), QToolBarAreaLayoutItem::realSizeHint(), QSplitter::setStretchFactor(), QGraphicsProxyWidgetPrivate::setWidget_helper(), show(), QStackedLayout::sizeHint(), QToolBarLayout::updateGeomArray(), QScrollAreaPrivate::updateScrollBars(), QBoxLayoutItem::vStretch(), and QFormLayoutItem::vStretch().

◆ statusTip

QString QWidget::statusTip
private

the widget's status tip

By default, this property contains an empty string.

See also
toolTip whatsThis

Definition at line 207 of file qwidget.h.

◆ styleSheet

QString QWidget::styleSheet
private

the widget's style sheet

Since
4.2

The style sheet contains a textual description of customizations to the widget's style, as described in the Qt Style Sheets document.

Since Qt 4.5, Qt style sheets fully supports Mac OS X.

Warning
Qt style sheets are currently not supported for custom QStyle subclasses. We plan to address this in some future release.
See also
setStyle(), QApplication::styleSheet, {Qt Style Sheets}

Definition at line 220 of file qwidget.h.

Referenced by QApplication::setStyle(), and unstylable().

◆ toolTip

QString QWidget::toolTip
private

the widget's tooltip

Note that by default tooltips are only shown for widgets that are children of the active window. You can change this behavior by setting the attribute Qt::WA_AlwaysShowToolTips on the window, not on the widget with the tooltip.

If you want to control a tooltip's behavior, you can intercept the event() function and catch the QEvent::ToolTip event (e.g., if you want to customize the area for which the tooltip should be shown).

By default, this property contains an empty string.

See also
QToolTip statusTip whatsThis

Definition at line 204 of file qwidget.h.

Referenced by QAccessibleDisplay::imageDescription(), and QAccessibleWidget::text().

◆ updatesEnabled

bool QWidget::updatesEnabled
inlineprivate

whether updates are enabled

An updates enabled widget receives paint events and has a system background; a disabled widget does not. This also implies that calling update() and repaint() has no effect if updates are disabled.

By default, this property is true.

setUpdatesEnabled() is normally used to disable updates for a short period of time, for instance to avoid screen flicker during large changes. In Qt, widgets normally do not generate screen flicker, but on X11 the server might erase regions on the screen when widgets get hidden before they can be replaced by other widgets. Disabling updates solves this.

Example:

bigVisualChanges();

Disabling a widget implicitly disables all its children. Enabling a widget enables all child widgets except top-level widgets or those that have been explicitly disabled. Re-enabling updates implicitly calls update() on the widget.

See also
paintEvent()

Definition at line 190 of file qwidget.h.

Referenced by discardInvalidateBufferRequest(), make_widget_eventUPP(), QWidgetBackingStore::markDirty(), QWidgetPrivate::moveRect(), QWidgetPrivate::paintSiblingsRecursive(), QStackedLayout::setCurrentIndex(), setParent(), and QWidgetBackingStore::sync().

◆ visible

QWidget::visible
private

whether the widget is visible

Calling setVisible(true) or show() sets the widget to visible status if all its parent widgets up to the window are visible. If an ancestor is not visible, the widget won't become visible until all its ancestors are shown. If its size or position has changed, Qt guarantees that a widget gets move and resize events just before it is shown. If the widget has not been resized yet, Qt will adjust the widget's size to a useful default using adjustSize().

Calling setVisible(false) or hide() hides a widget explicitly. An explicitly hidden widget will never become visible, even if all its ancestors become visible, unless you show it.

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.

A widget that happens to be obscured by other windows on the screen is considered to be visible. The same applies to iconified windows 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.

You almost never have to reimplement the setVisible() 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 the Polish event delivered to the event() function.

See also
show(), hide(), isHidden(), isVisibleTo(), isMinimized(), showEvent(), hideEvent()

Definition at line 191 of file qwidget.h.

Referenced by QPlainTextEditPrivate::ensureCursorVisible(), QPlainTextEdit::mouseMoveEvent(), QTextEdit::mouseMoveEvent(), QGLOverlayWidget::paintGL(), QMenuPrivate::scrollMenu(), QPrintDialogPrivate::selectPrinter(), QPlainTextEdit::setBackgroundVisible(), QLineEditPrivate::setCursorVisible(), QCalendarWidget::setNavigationBarVisible(), QDial::setNotchesVisible(), QColumnView::setResizeGripsVisible(), QProgressBar::setTextVisible(), setWindowFlags(), QPlainTextEdit::timerEvent(), QTextEdit::timerEvent(), and QColumnViewPrivate::updateScrollbars().

◆ whatsThis

QString QWidget::whatsThis
private

the widget's What's This help text.

By default, this property contains an empty string.

See also
QWhatsThis QWidget::toolTip QWidget::statusTip

Definition at line 210 of file qwidget.h.

Referenced by QDialog::contextMenuEvent(), and QAccessibleWidget::text().

◆ width

int QWidget::width
inlineprivate

the width of the widget excluding any window frame

See the Window Geometry documentation for an overview of geometry issues with windows.

Note
Do not use this function to find the width of a screen on a multiple screen desktop. Read this note for details.

By default, this property contains a value that depends on the user's platform and screen geometry.

See also
geometry, height, size

Definition at line 166 of file qwidget.h.

Referenced by QPlainTextEditPrivate::_q_adjustScrollbars(), QTextEditPrivate::_q_ensureVisible(), QTextEditPrivate::_q_repaintContents(), QPlainTextEditPrivate::_q_repaintContents(), QAxServerBase::ActiveXProc(), QDialog::adjustPosition(), QWorkspaceChild::adjustToFullscreen(), QWidgetAnimator::animate(), QApplicationPrivate::applyX11SpecificCommandLineArguments(), QMacStylePrivate::aquaSizeConstrain(), QWorkspace::arrangeIcons(), QPainterPrivate::attachPainterPrivate(), QGraphicsView::centerOn(), QAccessibleWidget::childAt(), QAccessibleComboBox::childAt(), QAccessibleMainWindow::childAt(), QWidgetPrivate::clipRect(), QLayout::closestAcceptableSize(), QSizeGripPrivate::corner(), QColumnViewPrivate::createColumn(), QXIMInputContext::createICData(), QEgl::createSurface(), distance(), QColumnViewPrivate::doLayout(), QWidgetResizeHandler::doResize(), drawTabBase(), dumpRecursive(), QGraphicsView::ensureVisible(), QMacWindowSurface::flush(), QPixmap::grabWidget(), QPixmap::grabWindow(), QListModeViewBase::indexToListViewItem(), QWorkspacePrivate::insertIcon(), make_widget_eventUPP(), QListModeViewBase::mapToViewport(), QStatusBarPrivate::messageRect(), QMenuBar::minimumSizeHint(), QColumnViewGrip::mouseDoubleClickEvent(), QWidgetResizeHandler::mouseMoveEvent(), QWorkspaceTitleBar::mouseMoveEvent(), QSizeGrip::mousePressEvent(), QColumnViewGrip::moveGrip(), QTreeViewPrivate::paintAlternatingRowColors(), QTableView::paintEvent(), parseGeometry(), QWorkspacePrivate::place(), QRasterWindowSurface::prepareBuffer(), QDirectFbWindow::QDirectFbWindow(), QOpenKODEWindow::QOpenKODEWindow(), QRollEffect::QRollEffect(), qt_aqua_guess_size(), qt_grab_cursor(), QXcbWindow::QXcbWindow(), QXlibWindow::QXlibWindow(), QMdi::IconTiler::rearrange(), QAccessibleWidget::rect(), QTextEditPrivate::relayoutDocument(), QPlainTextEditPrivate::relayoutDocument(), QHeaderViewPrivate::resizeSections(), QColumnView::scrollTo(), QTableViewPrivate::selectRow(), QAbstractItemViewPrivate::setHoverIndex(), QHeaderView::setOffsetToLastSection(), QHeaderViewPrivate::setupSectionIndicator(), QCompleterPrivate::showPopup(), QMenuBar::sizeHint(), QCommonListViewBase::updateHorizontalScrollBar(), QGLContext::updatePaintDevice(), QGraphicsViewPrivate::updateRect(), QGraphicsViewPrivate::updateRegion(), QFocusFramePrivate::updateSize(), QScrollAreaPrivate::updateWidgetPosition(), and QWorkspacePrivate::updateWorkspace().

◆ windowFilePath

QString QWidget::windowFilePath
private

the file path associated with a widget

Since
4.4

This property only makes sense for windows. It associates a file path with a window. If you set the file path, but have not set the window title, Qt sets the window title to contain a string created using the following components.

On Mac OS X:

On Windows and X11:

If the window title is set at any point, then the window title takes precedence and will be shown instead of the file path string.

Additionally, on Mac OS X, this has an added benefit that it sets the proxy icon for the window, assuming that the file path exists.

If no file path is set, this property contains an empty string.

By default, this property contains an empty string.

See also
windowTitle, windowIcon

Definition at line 223 of file qwidget.h.

◆ windowIcon

QIcon QWidget::windowIcon
private

◆ windowIconText

QString QWidget::windowIconText
private

the widget's icon text

This property only makes sense for windows. If no icon text has been set, this functions returns an empty string.

See also
windowIcon, windowTitle

Definition at line 200 of file qwidget.h.

◆ windowModality

Qt::WindowModality QWidget::windowModality
private

which windows are blocked by the modal widget

Since
4.1

This property only makes sense for windows. A modal widget prevents widgets in other windows from getting input. The value of this property controls which windows are blocked when the widget is visible. Changing this property while the window is visible has no effect; you must hide() the widget first, then show() it again.

By default, this property is Qt::NonModal.

See also
isWindow(), QWidget::modal, QDialog

Definition at line 156 of file qwidget.h.

Referenced by QApplicationPrivate::isBlockedByModal(), qt_mac_is_macsheet(), qt_mac_should_disable_menu(), and QWidgetPrivate::setModal_sys().

◆ windowModified

QWidget::windowModified
private

whether the document shown in the window has unsaved changes

A modified window is a window whose content has changed but has not been saved to disk. This flag will have different effects varied by the platform. On Mac OS X the close button will have a modified look; on other platforms, the window title will have an '*' (asterisk).

The window title must contain a "[*]" placeholder, which indicates where the '*' should appear. Normally, it should appear right after the file name (e.g., "document1.txt[*] - Text Editor"). If the window isn't modified, the placeholder is simply removed.

Note that if a widget is set as modified, all its ancestors will also be set as modified. However, if you call {setWindowModified(false)} on a widget, this will not propagate to its parent because other children of the parent might have been modified.

See also
windowTitle, {Application Example}, {SDI Example}, {MDI Example}

Definition at line 202 of file qwidget.h.

Referenced by QMdiSubWindow::eventFilter().

◆ windowOpacity

qreal QWidget::windowOpacity
private

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 available on Embedded Linux, Mac OS X, Windows, and X11 platforms that support the Composite extension.

This feature is not available on Windows CE.

Note that under X11 you need to have a composite manager running, and the X11 specific _NET_WM_WINDOW_OPACITY atom needs to be supported by the window manager you are using.

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 significantly slower than opaque windows.
See also
setMask()

Definition at line 201 of file qwidget.h.

Referenced by _q_paintItem(), QGraphicsScenePrivate::drawItemHelper(), QDirectFBWindowSurface::flush(), QRasterWindowSurface::flush(), QDirectFBWindowSurface::QDirectFBWindowSurface(), and QDirectFBWindowSurface::updateIsOpaque().

◆ windowTitle

QString QWidget::windowTitle
private

the window title (caption)

This property only makes sense for top-level widgets, such as windows and dialogs. If no caption has been set, the title is based of the windowFilePath . If neither of these is set, then the title is an empty string.

If you use the windowModified mechanism, the window title must contain a "[*]" placeholder, which indicates where the '*' should appear. Normally, it should appear right after the file name (e.g., "document1.txt[*] - Text Editor"). If the windowModified property is false (the default), the placeholder is simply removed.

See also
windowIcon, windowIconText, windowModified, windowFilePath

Definition at line 198 of file qwidget.h.

Referenced by AccessibleFactory::create(), QFileDialogPrivate::createNavServicesDialog(), QVistaHelper::drawTitleBar(), QWorkspace::eventFilter(), QWorkspaceChild::QWorkspaceChild(), QWorkspaceTitleBar::QWorkspaceTitleBar(), QMdiSubWindowPrivate::removeBaseWidget(), QToolBarAreaLayout::saveState(), QPrintDialogPrivate::setTabs(), QGraphicsProxyWidgetPrivate::setWidget_helper(), QCoreFuriCuri::timerEvent(), QMdiSubWindowPrivate::updateWindowTitle(), QDecorationDefault::windowTitleFor(), and QWSWindowSurface::winId().

◆ x

int QWidget::x
private

◆ y

int QWidget::y
private

The documentation for this class was generated from the following files: