The QWidget class is the base class of all user interface objects. (details) (complete member list)
#include <qwidget.h>
Inherits QObject and QPaintDevice.
Inherited by QButton, QComboBox, QFrame, QLineEdit, QMenuBar, QScrollBar and QView.
A widget without a parent, called a top level widget, is a window with a frame and title bar (depends on the widget style specified by the widget flags).
A widget with a parent becomes a child window in the parent's window.
Constructs a widget which is a child of parent, with the name name and widget flags set to f.
If parent is 0, the new widget will be a top level window. If parent is another widget, the new widget will be a child window inside parent.
The name is sent to the QObject constructor.
The widget flags are strictly internal. You are strongly advised to use 0.
Destroys the widget.
All children of this widget are deleted first. The application exits if this widget is (was) the main widget.
Returns the background color of this widget.
The background color is independent of the color group. The background color will be overwritten when setting a new palette.
See also: setBackgroundColor().
.
Closes this widget. First it sends the widget a QCloseEvent, then, if the widget did accept that, it does an explicit delete of the widget and all its children.
This event handler can be reimplemented in a sub class to receive widget close events.
The default implementation does nothing.
See also: event().
Returns the current color group of the widget palette.
The color group is determined by the state of the widget.
A disabled widget returns the QPalette::disabled() color group.
A widget in focus returns the QPalette::active() color group.
A normale widget returns the QPalette::normal() color group.
See also: palette() and setPalette().
.
Returns the widget cursor shape.
See also: setCursor().
.
This signal is emitted immediately before the widget is destroyed.
All the widget's children will be destroyed before the signal is emitted.
Disables the widget so that it will not receive mouse and keyboard events.
See also: enable() and isDisabled().
Writes s to position p. The y position is the base line, not the top or bottom of the text. The text is drawn in the current font and so on.
See also: setFont(), FontMetrics(), QPainter::drawText.
Writes str to position x,y. The y position is the base line, not the top or bottom of the text. The text is drawn in the current font and so on.
See also: setFont(), FontMetrics(), QPainter::drawText.
Enables the widget so that it can receive mouse and keyboard events.
See also: disable() and isDisabled().
Enables or disables updates of this widget. If updates are disabled, the widget will not receive repaint events.
Clears the widget on-screen. Child widgets are not disturbed, and repaint events are not generated.
This is the main event handler. You may reimplement this function in a sub class, but we recommend using one of the specialized event handlers instead.
The main event handler first passes an event through all event filters that have been installed (see QObject::installEventFilter()). If none of the filters intercept the event, it calls one of the specialized event handlers.
Key press/release events are treated differently from other events. First it checks if there exists an accelerator object (QAccel) that want the key press (accelerators do not get key release events). If not, it sends the event to the widget that has the keyboard focus. If there is no widget in focus or the focus widget did not want the key, the event is sent to the top level widget.
This function returns TRUE if it is able to pass the event over to someone, or FALSE if nobody wanted the event.
See also: QObject::event(), closeEvent(), focusInEvent(), focusOutEvent(), keyPressEvent(), keyReleaseEvent(), mouseDoubleClickEvent(), mouseMoveEvent(), mousePressEvent(), mouseReleaseEvent(), moveEvent(), paintEvent(), resizeEvent() and timerEvent().
Returns a pointer to the widget with Window ID id. The Window ID type depends by the underlying window system, see qwindefs.h for the actual definition. If there is no widget with ID id, a null pointer is returned.
This event handler can be reimplemented in a sub class to receive keyboard focus events (focus received) for the widget.
The default implementation does nothing.
See also: focusOutEvent() and event(). Reimplemented in QLineEdit.
.
This event handler can be reimplemented in a sub class to receive keyboard focus events (focus lost) for the widget.
The default implementation does nothing.
See also: focusInEvent() and event(). Reimplemented in QLineEdit.
.
Returns the font currently set for the widget.
QFontInfo will tell you what font is actually being used.
See also: setFont(), fontMetrics() and fontInfo().
Returns the font information of the font currently in use by this widget.
See also: fontMetrics(), font() and setFont().
Returns the font metrics of the font currently in use by this widget.
See also: fontInfo(), font() and setFont().
Returns the foreground color of this widget.
The foreground color equals colorGroup().foreground()
.
See also: backgroundColor() and colorGroup().
Returns the geometry of the widget, relative to its parent and including any frame the window manager decides to decorate the window with.
See also: geometry().
Returns the geometry of the widget, relative to its parent widget and excluding frames and other decorations.
See also: frameGeometry(), QRect, size(), x(), y(), pos(), and rect().
.
Grabs the keyboard input focus.
This widget will receive all keyboard events, no matter where the mouse cursor is.
See also: releaseKeyboard(), grabMouse(), releaseMouse().
Grabs the mouse input.
The widget will continue to get mouse events until releaseMouse() is called.
Warning: This might lock your terminal.
It is almost never necessary to grab the mouse when using Qt since Qt grabs and releases it sensibly. In particular, Qt grabs the mouse when a button is pressed and keeps it until the last button is released.
See also: releaseMouse().
Grabs the mouse intput and change the cursor shape.
The cursor will assume shape cursor (for as long as the mouse focus is grabbed) and the widget will continue getting mouse events until releaseMouse() is called().
See also: releaseMouse(), setCursor().
Returns TRUE if the widget (not one of its children) has the keyboard focus.
Returns the height of the widget, excluding any window frames.
Makes the widget invisible.
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.
See also: find().
Returns TRUE if the widget is disabled, or FALSE if it is enabled.
See also: enable() and disable().
Returns TRUE if the widget is visible, or FALSE if the widget is invisible.
Calling show() makes the widget visible. Calling hide() makes the widget invisible.
A widget is considered visible even if it is obscured by other windows on the screen.
This event handler can be reimplemented in a sub class to receive key press events for the widget.
The default implementation ignores the key.
See also: keyReleaseEvent() and event(). Reimplemented in QLineEdit and QScrollBar.
This event handler can be reimplemented in a sub class to receive key release events for the widget.
The default implementation ignores the key.
See also: keyPressEvent() and event().
Lowers the widget to the bottom of the windows stack. Only the parent window will be behind this one afterwards.
Translates the global screen coordinate pos to widget coordinates.
See also: mapToGlobal().
Translates the parent widget coordinate pos to widget coordinates.
Same as mapFromGlobal() if the widget has no parent.
See also: mapToParent().
Translates the widget coordinate pos to global screen coordinates.
See also: mapFromGlobal().
Translates the widget coordinate pos to a coordinate in the parent widget.
Same as mapToGlobal() if the widget has no parent.
See also: mapFromParent().
Returns any of several widget metrics. This may be of use e.g. for selecting monochrome or color appearance in a widget, but application programmers should use QPaintDeviceMetrics instead, or even better, write code that works without depending on these metrics.
The metric commands are defined in qpaintdc.h. At the time of
writing, PDM_WIDTH, PDM_HEIGHT, PDM_WIDTHMM, PDM_HEIGHTMM,
PDM_NUMCOLORS
and PDM_NUMPLANES
are supported. PDM_NUMCOLORS
returns the number of actual colors, not the number of
possible colors, use PDM_NUMPLANES if that's what you want.
This event handler can be reimplemented in a sub class to receive mouse double click events for the widget.
The default implementation generates a normal mouse press event.
See also: mousePressEvent() and event().
This event handler can be reimplemented in a sub class to receive mouse move events for the widget.
If mouse tracking is switched off, mouse move events will only occur if a mouse button is down. If mouse tracking is swithed on, mouse move events will occur even if no mouse button is down.
The default implementation does nothing.
See also: setMouseTracking() and event(). Reimplemented in QButton and QScrollBar.
This event handler can be reimplemented in a sub class to receive mouse press events for the widget.
The default implementation does nothing.
See also: mousePressEvent() and event(). Reimplemented in QButton, QLineEdit and QScrollBar.
This event handler can be reimplemented in a sub class to receive mouse release events for the widget.
The default implementation does nothing.
See also: mousePressEvent() and event(). Reimplemented in QButton and QScrollBar.
Moves the widget. x and y are relative to the widget's parent. If necessary, the window manager is told about the change. A move event is sent at once.
See also: resize(), setGeometry(), QWidget::moveEvent().
Moves the widget to position p, which is relative to the widget's arent. If necessary, the window manager is told about the change. A move event is sent at once.
See also: resize(), setGeometry(), moveEvent().
This event handler can be reimplemented in a sub class to receive widget move events.
The default implementation does nothing.
See also: resizeEvent() and event().
This event handler can be reimplemented in a sub class to receive widget paint events.
The default implementation does nothing.
See also: event(). Reimplemented in QButton, QFrame and QScrollBar.
Returns the widget palette.
See also: setPalette() and colorGroup().
Returns a pointer to the parent of this widget, or a null pointer if it does not have any parent widget.
Returns the postion of the widget in its parent widget, excluding frames and other decorations.
See also: frameGeometry(), x() and y().
Raises the widget to the top of the window stack.
This function is provided in case a widget should feel really bad, regret that it was even born.
It gives the widget a fresh start, new parent, new widget flags (f but as usual, use 0) at a new position in its new parent (p).
If showIt is TRUE, show() is called once the widget has been recreated.
Returns the the internal geometry of the widget, excluding any window frames. rect() equals QRect(0,0,width(),height()).
See also: size().
Releases the keyboard focus. The keyboard events will follow their natural inclination.
See also: grabKeyboard(), grabMouse(), releaseMouse().
Releases the mouse from a grab.
Repaints the widget directly.
Doing a repaint() is faster than doing an update(), but since repaint() does not make a server trip and there is some time skew between the server and client, your client may get confused.
Repaints the widget directly.
Doing a repaint() is faster than doing an update(), but since repaint() does not make a server trip and there is some time skew between the server and client, your client may get confused.
Repaints the widget directly.
This function is virtual, and the other overloaded repaint()s call it, but reimplementing it is strongly discouraged. FYI, QTableWidget reimplements it.
Doing a repaint() is faster than doing an update(), but since repaint() does not make a server trip and there is some time skew between the server and client, your client may get confused.
Resizes the widget to size w pixels by h. If necessary, the window manager is told about the change. A resize event is sent at once.
See also: move(), setGeometry(), resizeEvent().
Resizes the widget to size p. If necessary, the window manager is told about the change. A resize event is sent at once.
See also: move(), setGeometry(), resizeEvent().
This event handler can be reimplemented in a sub class to receive widget resize events.
The default implementation does nothing.
See also: moveEvent() and event(). Reimplemented in QScrollBar.
Move the contents of the widget dx pixels rightwards and dy pixels downwards. If dx/dy is negative, the move is leftwards/upwards. Child widgets are moved accordingly.
The leftmost/top/rightmost/bottom (you know where) part of the widget is cleared, and repaint events will eventually be generated for it. It's better, though, to redraw at once, if you wait for repaint() the screen may flicker.
If there are windows on top of your widget, you will get repaint events for areas of your widget that are scrolled.
See also: setBackgroundColor(), setBackgroundPixmap().
Enables or disables the keyboard input focus events for the widget.
Focus events are initially disabled.
Sets the background color of this widget.
The background color is independent of the widget color group.
Notice that the background color will be overwritten when setting
a new palette.
See also: backgroundColor() and setPalette(). Reimplemented in QComboBox.
Sets the background pixmap of the widget to pm.
The background pixmap is tiled.
.
Sets the widget cursor shape.
The mouse cursor will assume this shape when it's over this widget. The available shapes are listed in the QCursor documentation.
An editor widget would for example use an I-beam cursor:
setCursor( ibeamCursor );
See also: cursor().
.
.
Gives this widget the keyboard input focus.
Sets the font of the widget.
The fontInfo() function reports the actual font that is being used by the widget.
This code fragment switches to a bold version of whatever font is being used:
QFont f = font();
f.setWeight( QFont::Bold );
setFont( f );
See also: font() and fontInfo(). Reimplemented in QComboBox.
Changes the widget geometry to r, relative to its parent widget. If necessary, the window manager is informed. First a resize and then a move event is sent to the widget itself.
Changes the widget geometry to w pixels by h, positioned at x,y in its parent widget. If necessary, the window manager is informed. First a resize and then a move event is sent to the widget itself.
This function is virtual, and all other overloaded setGeometry() implementations call it.
Sets the maximum size of the widget to w pixels wide and h pixels high. The user will not be able to resize the widget to a larger size.
See also: setMinimumSize(), setSizeIncrement(), size() and geometry().
Sets the minimum size of the widget to w pixels wide and h pixels high. The user will not be able to resize the widget to a smaller size.
See also: setMaximumSize(), setSizeIncrement(), size() and geometry().
Enables or disables mouse tracking and returns the previous setting.
If mouse tracking is enabled, the widget will always receive mouse move events, even when no mouse button is pressed down.
If mouse tracking is disabled (default), the widget will only receive mouse move events when a mouse button is pressed down.
See also: mouseMoveEvent().
Sets the widget palette to p. The widget background color is set to
colorGroup().background()
.
See also: palette() and colorGroup(). Reimplemented in QComboBox and QScrollBar.
Sets the size increment of the widget. When the user resizes the widget, the size will move in steps of w horizontally and h vertically. Both default to 1.
See also: setMaximumSize() and setSizeIncrement().
Sets the GUI style of the widget.
Only MotifStyle
is allowed in this version of Qt.
See also: style() and QApplication::setStyle().
Makes the widget and its children visible on the screen.
Returns the size of the widget, excluding any window frames.
See also: geometry(), width() and height().
Returns the GUI style of the widget.
See also: setStyle() and QApplication::style().
Returns non-zero if any of the widget flags in n are set. The widget flags are listed in qwindefs.h, and are strictly for internal use.
This event handler can be reimplemented in a sub class to receive timer events for the widget.
The default implementation does nothing.
See also: QObject::startTimer(), QObject::killTimer() and event(). Reimplemented in QLineEdit and QScrollBar.
Updates the entire widget. If updates are enabled, of course. The default action of this is to clear the widget, so widgets that wish to actually interact with the user should reimplement it.
Updates a rectangle (x, y, w, h) inside the widget.
Calling update() will generate a paint event from the X server.
Returns the width of the widget, excluding any window frames.
See also: size() and height().
.
Returns the x coordinate of the widget, relative to its parent widget and excluding frames and other decorations.
See also: geometry(), pos() and y().
Returns the y coordinate of the widget, relative to its parent widget and excluding frames and other decorations.
See also: geometry(), pos() and x().
This file is part of the Qt toolkit, copyright 1995 Troll Tech, all rights reserved.
It was generated from the following files: