The QWidget class is the base class of all user interface objects. More...
#include <qwidget.h>
Inherits QObject and QPaintDevice.
Inherited by QButton, QComboBox, QDialog, QFrame, QLineEdit, QScrollBar and QWindow.
It receives mouse, keyboard and other events from the window system. It has a number of virtual functions which can be reimplemented in order to respond to these events.
By far the most important is paintEvent() which is called whenever the widget needs to update its on-screen representation. Other commonly implemented events include resizeEvent(), keyPressEvent(), mousePressEvent() etc.
A widget without a parent, called a top-level widget, is a window with a frame and title bar (depending on the widget style specified by the widget flags). A widget with a parent is a child window in its parent.
See also: QEvent and QPainter.
Examples: tictac/tictac.cpp dclock/dclock.cpp forever/forever.cpp connect/connect.cpp aclock/aclock.cpp menu/menu.cpp qmag/qmag.cpp widgets/widgets.cpp
Constructs a widget which is a child of parent, with the name name and widget flags set to f.
If parent is 0, the new widget becomes a top-level window. If parent is another widget, this widget becomes a child window inside parent.
The name is sent to the QObject constructor.
The widget flags argument f is normally 0, but it can be set to
customize the window frame of a top-level widget (i.e. parent must be
zero). To customize the frame, set the WStyle_Customize
flag OR'ed with
any of these flags:
WStyle_NormalBorder
gives the window a normal border. Cannot
be combined with WStyle_DialogBorder
or WStyle_NoBorder.
WStyle_DialogBorder
gives the window a thin dialog border.
Cannot be combined with WStyle_NormalBorder
or WStyle_NoBorder.
WStyle_NoBorder
gives a borderless window. Note that the
user cannot move or resize a borderless window via the window system.
Cannot be combined with WStyle_NormalBorder
or WStyle_DialogBorder.
WStyle_Title
gives the window a title bar.
WStyle_SysMenu
adds a window system menu.
WStyle_Minimize
adds a minimize button.
WStyle_Maximize
adds a maximize button.
WStyle_MinMax
is equal to (WStyle_Minimize | WStyle_Maximize)
.
WStyle_Tool
makes the window a tool window, usually
combined with WStyle_NoBorder.
A tool window is a small window that
lives for a short time and it is typically used for creating popup
windows.
Note that X11 does not necessarily support all style flag combinations. X11 window managers live their own lives and can only take hints. Win32 supports all style flags.
Example:
QLabel *toolTip = new QLabel( 0, "myToolTip", WStyle_Customize | WStyle_NoBorder | WStyle_Tool );
The widget flags are defined in qwindefs.h (which is included by qwidget.h).
Destroys the widget.
All children of this widget are deleted first. The application exits if this widget is (was) the main widget.
[protected]
Returns TRUE if the widget accepts keyboard focus events, or FALSE if it does not.
Focus events are initially disabled, so the widget cannot receive keyboard input. Call setAcceptFocus(TRUE) to enable focus events and keyboard events.
See also: setAcceptFocus(), focusInEvent(), focusOutEvent(), keyPressEvent(), keyReleaseEvent(), enable() and disable().
[virtual]
Adjusts the size of the widget to fit the contents. Uses sizeHint() if valid, otherwise sets the size to the children rectangle.
See also: sizeHint() and childrenRect().
Examples: widgets/widgets.cpp
Reimplemented in QMessageBox.
Returns the background color of this widget.
The background color is independent of the color group.
Setting a new palette overwrites the background color.
See also: setBackgroundColor(), foregroundColor(), colorGroup() and palette().
[virtual protected]
This virtual function is called from setBackgroundColor(). oldBackgroundColor is the previous background color; you can get the new background color from backgroundColor().
Reimplement this function if your widget needs to know when its background color changes. You will almost certainly need to update the widget using either repaint(TRUE) or update().
The default implementation calls update().
See also: setBackgroundColor(), backgroundColor(), setPalette(), repaint() and update().
Returns the background pixmap, or null if no background pixmap has not been set.
See also: setBackgroundPixmap().
[virtual protected]
This virtual function is called from setBackgroundPixmap(). oldBackgroundPixmap is the previous background pixmap; you can get the new background pixmap from backgroundPixmap().
Reimplement this function if your widget needs to know when its background pixmap changes. You will almost certainly need to update the widget using either repaint(TRUE) or update().
The default implementation calls update().
See also: setBackgroundPixmap(), backgroundPixmap(), repaint() and update().
Returns the widget caption, or null if no caption has been set.
See also: setCaption(), icon() and iconText().
Returns the bounding rectangle of the widget's children.
Takes keyboard input focus from the widget.
A focus out event is sent to this widget to tell it that it is about to loose the focus.
This widget must enable focus setting in order to get the keyboard input focus, i.e. it must call setAcceptFocus(TRUE).
Warning: If you call clearFocus() in a function which may itself be called from focusOutEvent(), you may see infinite recursion.
See also: hasFocus(), setFocus(), focusInEvent(), focusOutEvent(), setAcceptFocus() and QApplication::focusWidget().
[protected]
For internal use only.
[virtual]
Closes this widget. Returns TRUE if the widget was closed, otherwise FALSE.
First it sends the widget a QCloseEvent. The widget is hidden if it accepts the close event. The default implementation of QWidget::closeEvent() accepts the close event.
If forceKill is TRUE, the widget is deleted whether it accepts the close event or not.
The application is terminated when the main widget is closed.
See also: closeEvent(), QCloseEvent, hide(), QApplication::quit() and QApplication::setMainWidget().
[virtual protected]
This event handler can be reimplemented in a subclass to receive widget close events.
The default implementation calls e->accept(), which hides this widget. See the QCloseEvent documentation for more details.
See also: event(), hide(), close() and QCloseEvent.
Reimplemented in QDialog.
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 and a normal widget returns the QPalette::normal() color group.
See also: palette() and setPalette().
Returns the widget cursor.
See also: setCursor().
Writes str at position x,y.
The y position is the base line position of the text. The text is drawn using the current font and the current foreground color.
This function is provided for convenience. You will generally get more flexible results and often higher speed by using a a painter instead.
See also: setFont(), foregroundColor() and QPainter::drawText().
Examples: showimg/showimg.cpp
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it takes.
[virtual protected]
This virtual function is called from setEnabled(). oldEnabled is the previous setting; you can get the new setting from enabled().
Reimplement this function if your widget needs to know when it becomes enabled or disabled. You will almost certainly need to update the widget using either repaint(TRUE) or update().
The default implementation calls repaint(TRUE).
See also: setEnabled(), enabled(), repaint() and update().
[virtual protected]
This event handler can be reimplemented in a subclass to receive widget enter events.
An event is sent to the widget when the mouse cursor enters the widget.
The default implementation does nothing.
See also: leaveEvent(), mouseMoveEvent() and event().
Erases the specified area (x,y,w,h) in the widget without generating a paint event.
If w is negative, it is replaced with width() - x
.
If h is negative, it is replaced width height() - y
.
Child widgets are not affected.
See also: repaint().
Examples: connect/connect.cpp
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it takes.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it takes.
This version erases the entire widget.
[virtual protected]
This is the main event handler. You may reimplement this function in a subclass, 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. 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. 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().
This function returns TRUE if it is able to pass the event over to someone, or FALSE if nobody wanted the event.
See also: closeEvent(), focusInEvent(), focusOutEvent(), enterEvent(), keyPressEvent(), keyReleaseEvent(), leaveEvent(), mouseDoubleClickEvent(), mouseMoveEvent(), mousePressEvent(), mouseReleaseEvent(), moveEvent(), paintEvent(), resizeEvent(), QObject::event() and QObject::timerEvent().
Reimplemented from QObject.
[protected]
For internal use only.
[static]
Returns a pointer to the widget with window identifer/handle id.
The window identifier type depends by the underlying window system, see qwindefs.h for the actual definition. If there is no widget with this identifier, a null pointer is returned.
See also: wmapper() and id().
[virtual protected]
This event handler can be reimplemented in a subclass to receive keyboard focus events (focus received) for the widget.
A widget must accept focus initially in order to receive focus events.
The default implementation calls repaint() since the widget's color group changes from normal to active. You may want to call repaint(FALSE) to reduce flicker in any reimplementation.
See also: focusOutEvent(), setAcceptFocus(), keyPressEvent(), keyReleaseEvent(), event() and QFocusEvent.
Reimplemented in QLineEdit, QListBox and QButton.
[virtual protected]
For internal use only.
[virtual protected]
This event handler can be reimplemented in a subclass to receive keyboard focus events (focus lost) for the widget.
A widget must accept focus initially in order to receive focus events.
The default implementation calls repaint() since the widget's color group changes from active to normal. You may want to call repaint(FALSE) to reduce flicker in any reimplementation.
See also: focusInEvent(), setAcceptFocus(), keyPressEvent(), keyReleaseEvent(), event() and QFocusEvent.
Reimplemented in QButton and QLineEdit.
Returns the font currently set for the widget.
fontInfo() tells you what font is actually being used.
See also: setFont(), fontInfo() and fontMetrics().
Examples: xshape/xshape.cpp
[virtual protected]
This virtual function is called from setFont(). oldFont is the previous font; you can get the new font from font().
Reimplement this function if your widget needs to know when its font changes. You will almost certainly need to update the widget using either repaint(TRUE) or update().
The default implementation calls update().
See also: setFont(), font(), repaint() and update().
Reimplemented in QMenuBar.
Returns the font info for the widget.
See also: font(), fontMetrics() and setFont().
Returns the font metrics for the widget.
See also: font(), fontInfo() and setFont().
Examples: drawdemo/drawdemo.cpp qmag/qmag.cpp
Returns the foreground color of this widget.
The foreground color equals colorGroup().foreground()
.
See also: backgroundColor() and colorGroup().
Examples: aclock/aclock.cpp
Returns the geometry of the widget, relative to its parent and including the window frame.
See also: geometry(), x(), y() and pos().
Returns the geometry of the widget, relative to its parent widget and excluding the window frame.
See also: frameGeometry(), size() and rect().
Examples: qmag/qmag.cpp
[protected]
For internal use only.
Grabs all keyboard input.
This widget will receive all keyboard events, independent of the active window.
Warning: Grabbing the keyboard might lock the terminal.
See also: releaseKeyboard(), grabMouse() and releaseMouse().
Grabs the mouse intput and changes the cursor shape.
The cursor will assume shape cursor (for as long as the mouse focus is grabbed) and this widget will be the only one to receive mouse events until releaseMouse() is called().
Warning: Grabbing the mouse might lock the terminal.
See also: releaseMouse(), grabKeyboard(), releaseKeyboard() and setCursor().
Grabs the mouse input.
This widget will be the only one to receive mouse events until releaseMouse() is called.
Warning: Grabbing the mouse might lock the 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(), grabKeyboard() and releaseKeyboard().
Examples: qmag/qmag.cpp
Returns TRUE if this widget (not one of its children) has the keyboard input focus, otherwise FALSE.
Equivalent with qApp->focusWidget() == this
.
See also: setFocus(), clearFocus(), setAcceptFocus() and QApplication::focusWidget().
Returns TRUE if mouse tracking is enabled for this widget, or FALSE if mouse tracking is disabled.
See also: setMouseTracking().
Returns the height of the widget, excluding the window frame.
See also: geometry(), width() and size().
Examples: xshape/xshape.cpp drawdemo/drawdemo.cpp aclock/aclock.cpp showimg/showimg.cpp qmag/qmag.cpp widgets/widgets.cpp
[virtual]
Hides the widget.
See also: show(), iconify() and isVisible().
Reimplemented in QPopupMenu and QMenuBar.
Returns the widget icon pixmap, or null if no icon has been set.
See also: setIcon(), iconText() and caption().
Returns the widget icon text, or null if no icon text has been set.
See also: setIconText(), icon() and caption().
Iconifies the widget.
Calling this function has no effect for other than top-level widgets.
See also: show(), hide() and isVisible().
Returns TRUE if the top-level widget containing this widget is the active window.
See also: setActiveWindow() and topLevelWidget().
Returns TRUE if the widget is a desktop widget, otherwise FALSE.
A desktop widget is also a top-level widget.
See also: isTopLevel() and QApplication::desktop().
Returns TRUE if the widget is enabled, or FALSE if it is disabled.
See also: setEnabled().
Returns TRUE if the widget is a modal widget, otherwise FALSE.
A modal widget is also a top-level widget.
See also: isTopLevel() and QDialog.
Returns TRUE if the widget is a popup widget, otherwise FALSE.
A popup widget is created by specifying the widget flag WType_Popup
to the widget constructor.
A popup widget is also a top-level widget.
See also: isTopLevel().
Returns TRUE if the widget is a top-level widget, otherwise FALSE.
A top-level widget is a widget which usually has a frame and a caption (title bar). Popup and desktop widgets are also top-level widgets. Modal dialog widgets are the only top-level widgets that can have parent widgets; all other top-level widgets have null parents. Child widgets are the opposite of top-level widgets.
See also: topLevelWidget(), isModal(), isPopup(), isDesktop() and parentWidget().
Returns TRUE if updates are enabled, otherwise FALSE.
See also: setUpdatesEnabled().
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.
[virtual protected]
This event handler can be reimplemented in a subclass to receive key press events for the widget.
A widget must 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 ignore() the press if you do not understand it, so that the widget's parent can interpret it.
The default implementation ignores the event.
See also: keyReleaseEvent(), QKeyEvent::ignore(), setAcceptFocus(), focusInEvent(), focusOutEvent(), event() and QKeyEvent.
Reimplemented in QMenuBar, QLineEdit, QScrollBar, QComboBox, QListBox, QPopupMenu and QDialog.
[virtual protected]
This event handler 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 ignore() the release if you do not understand it, so that the widget's parent can interpret it.
The default implementation ignores the event.
See also: keyPressEvent(), QKeyEvent::ignore(), setAcceptFocus(), focusInEvent(), focusOutEvent(), event() and QKeyEvent.
[static]
Returns a pointer to the widget that is currently grabbing the keyboard input.
If no widget in this application is currently grabbing the keyboard, 0 is returned.
See also: grabMouse() and mouseGrabber().
[virtual protected]
This event handler can be reimplemented in a subclass to receive widget leave events.
A leave event is sent to the widget when the mouse cursor leaves the widget.
The default implementation does nothing.
See also: enterEvent(), mouseMoveEvent() and event().
Lowers the widget to the bottom of the parent widget's stack.
If there are siblings of this widget that overlap it on the screen, this widget will be obscured by its siblings afterwards.
See also: raise().
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 the maximum widget size.
The widget cannot be resized to a larger size than the maximum widget size.
See also: setMaximumSize(), minimumSize() and sizeIncrement().
[virtual protected]
Internal implementation of the virtual QPaintDevice::metric() function.
Use the QPaintDeviceMetrics class instead.
Reimplemented from QPaintDevice.
Returns the minimum widget size.
The widget cannot be resized to a smaller size than the minimum widget size.
See also: setMinimumSize(), maximumSize() and sizeIncrement().
[virtual protected]
This event handler 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 that the widgets gets a mousePressEvent() and a mouseReleaseEvent() before the mouseDoubleClickEvent().
See also: mousePressEvent(), mouseReleaseEvent(), mouseMoveEvent(), event() and QMouseEvent.
Reimplemented in QLineEdit, QListBox and QComboBox.
[static]
Returns a pointer to the widget that is currently grabbing the mouse input.
If no widget in this application is currently grabbing the mouse, 0 is returned.
See also: grabMouse() and keyboardGrabber().
[virtual protected]
This event handler 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 down while the mouse is being moved. If mouse tracking is switched on, mouse move events occur even if no mouse button is down.
The default implementation does nothing.
See also: setMouseTracking(), mousePressEvent(), mouseReleaseEvent(), mouseDoubleClickEvent(), event() and QMouseEvent.
Reimplemented in QMenuBar, QScrollBar, QComboBox, QListBox, QPopupMenu and QButton.
[virtual protected]
This event handler can be reimplemented in a subclass to receive mouse press events for the widget.
The default implementation does nothing.
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.
See also: mouseReleaseEvent(), mouseDoubleClickEvent(), mouseMoveEvent(), event() and QMouseEvent.
Reimplemented in QMenuBar, QLineEdit, QComboBox, QListBox, QScrollBar, QPopupMenu and QButton.
[virtual protected]
This event handler can be reimplemented in a subclass to receive mouse release events for the widget.
The default implementation does nothing.
See also: mouseReleaseEvent(), mouseDoubleClickEvent(), mouseMoveEvent(), event() and QMouseEvent.
Reimplemented in QMenuBar, QLineEdit, QListBox, QScrollBar, QComboBox, QRadioButton, QPopupMenu and QButton.
[virtual]
Moves the widget to the position (x,y) relative to the parent widget.
A move event is generated immediately.
This function is virtual, and all other overloaded move() implementations call it.
Warning: If you call move() or setGeometry() from moveEvent(), you may see infinite recursion.
See also: pos(), resize(), setGeometry() and moveEvent().
Reimplemented in QDialog.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it takes.
Examples: drawdemo/drawdemo.cpp
[virtual protected]
This event handler can be reimplemented in a subclass to receive widget move events. When the widget receives this event, it is already at the new position.
The old position is accessible through QMoveEvent::oldPos().
The default implementation does nothing.
See also: resizeEvent(), event(), move() and QMoveEvent.
[virtual protected]
This event handler can be reimplemented in a subclass to receive widget paint events. Actually, it more or less must be reimplemented.
The default implementation does nothing.
When the paint event occurs, the update rectangle QPaintEvent::rect() normally has been cleared to the background color or pixmap. An exception is repaint() with erase=FALSE.
For many widgets it is sufficient to redraw the entire widget each time, but some need to consider the update rectangle to avoid flicker or slow update.
Pixmaps can also be used to implement flicker-free update.
update() and repaint() can be used to force a paint event.
See also: event(), repaint(), update(), QPainter, QPixmap and QPaintEvent.
Reimplemented in QFrame, QComboBox, QScrollBar, QTableView, QPopupMenu, QGroupBox and QButton.
Returns the widget palette.
See also: setPalette() and colorGroup().
[virtual protected]
This virtual function is called from setPalette(). oldPalette is the previous palette; you can get the new palette from palette().
Reimplement this function if your widget needs to know when its palette changes. You will almost certainly need to update the widget using either repaint(TRUE) or update().
The default implementation calls update().
See also: setPalette(), palette(), repaint() and update().
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, including the window frame.
See also: frameGeometry(), x() and y().
Raises this widget to the top of the parent widget's stack.
If there are any siblings of this widget that overlap it on the screen, this widget will be in front of its siblings afterwards.
See also: lower().
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.
See also: getWFlags().
Returns the the internal geometry of the widget, excluding the window frame. rect() equals QRect(0,0,width(),height()).
See also: size().
Examples: menu/menu.cpp
Releases the keyboard grab.
See also: grabKeyboard(), grabMouse() and releaseMouse().
Releases the mouse grab.
See also: grabMouse(), grabKeyboard() and releaseKeyboard().
Examples: qmag/qmag.cpp
Repaints the widget directly by calling paintEvent() directly, unless updates are disabled or the widget is hidden.
Erases the widget area (x,y,w,h) if erase is TRUE.
If w is negative, it is replaced with width() - x
.
If h is negative, it is replaced width height() - y
.
Doing a repaint() usually is faster than doing an update(), but calling update() many times in a row will generate a single paint event.
Warning: If you call repaint() in a function which may itself be called from paintEvent(), you may see infinite recursion. The update() function never generates recursion.
See also: update(), paintEvent(), setUpdatesEnabled() and erase().
Examples: forever/forever.cpp qmag/qmag.cpp
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it takes.
This version repaints the entire widget.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it takes.
Examples: forever/forever.cpp showimg/showimg.cpp
[virtual]
Resizes the widget to size w by h pixels.
A resize event is generated at once.
The size is adjusted if it is outside the minimum or maximum widget size.
This function is virtual, and all other overloaded resize() implementations call it.
Warning: If you call resize() or setGeometry() from resizeEvent(), you may see infinite recursion.
See also: size(), move(), setGeometry(), resizeEvent(), minimumSize() and maximumSize().
Examples: tictac/tictac.cpp xshape/xshape.cpp drawdemo/drawdemo.cpp showimg/showimg.cpp qmag/qmag.cpp widgets/widgets.cpp
Reimplemented in QPushButton and QDialog.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it takes.
[virtual protected]
This event handler can be reimplemented in a subclass to receive widget resize events. When resizeEvent() is called, the widget already has its new geometry.
The old size is accessible through QResizeEvent::oldSize().
The default implementation does nothing.
See also: moveEvent(), event(), resize() and QResizeEvent.
Reimplemented in QFileDialog, QFrame, QMenuBar, QMessageBox, QScrollBar, QLineEdit, QLCDNumber, QListBox and QTableView.
Scrolls the contents of the widget dx pixels rightwards and dy pixels downwards. If dx/dy is negative, the scroll direction is leftwards/upwards. Child widgets are moved accordingly.
The areas of the widget that are exposed will be erased and a paint event will be generated.
Warning: If you call scroll() in a function which may itself be called from the moveEvent() or paintEvent() of a direct child of the widget being scrolled, you may see infinite recursion.
See also: erase() and bitBlt().
[protected]
Enables or disables the keyboard input focus events for the widget.
Focus events are initially disabled. Enabling focus is normally done from a widget's constructor. For instance, the QLineEdit constructor does setAcceptFocus(TRUE).
See also: setAcceptFocus(), focusInEvent(), focusOutEvent(), keyPressEvent(), keyReleaseEvent(), enable() and disable().
Sets the top-level widget containing this widget to be the active window.
An active window is a 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.
See also: isActiveWindow() and topLevelWidget().
[virtual]
Sets the background color of this widget.
The background color is independent of the widget color group. Setting a new palette overwrites the background color.
See also: backgroundColor(), backgroundColorChange(), setPalette() and setBackgroundPixmap().
Examples: tictac/tictac.cpp xshape/xshape.cpp connect/connect.cpp drawdemo/drawdemo.cpp
Reimplemented in QTableView and QComboBox.
[virtual]
Sets the background pixmap of the widget to pixmap.
The background pixmap is tiled.
See also: backgroundPixmap(), backgroundPixmapChange() and setBackgroundColor().
[protected]
For internal use only.
Sets the window caption (title).
See also: caption(), setIcon() and setIconText().
Examples: drawdemo/drawdemo.cpp showimg/showimg.cpp widgets/widgets.cpp
[virtual]
Sets the widget cursor shape to cursor.
The mouse cursor will assume this shape when it's over this widget. See a list of cursor shapes in the QCursor documentation.
An editor widget would for example use an I-beam cursor:
setCursor( ibeamCursor );
See also: cursor() and QApplication::setOverrideCursor().
Examples: cursor/cursor.cpp
[virtual]
Enables widget input events if enable is TRUE, otherwise disables input events.
An enabled widget receives keyboard and mouse events; a disabled widget does not. Note that an enabled widget receives keyboard events only when it is in focus.
See also: isEnabled(), QKeyEvent and QMouseEvent.
[protected]
For internal use only.
Sets both the minimum and maximum sizes of the widget to s, thereby preventing it from ever growing or shrinking.
See also: setMaximumSize() and setMinimumSize().
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it takes.
Gives the keyboard input focus to the widget.
First, a focus out event is sent to the focus widget (if any) to tell it that it is about to loose the focus. Then a focus in event is sent to this widget to tell it that it just received the focus.
This widget must enable focus setting in order to get the keyboard input focus, i.e. it must call setAcceptFocus(TRUE).
Warning: If you call setFocus() in a function which may itself be called from focusOutEvent() or focusInEvent(), you may see infinite recursion.
See also: hasFocus(), clearFocus(), focusInEvent(), focusOutEvent(), setAcceptFocus() and QApplication::focusWidget().
[virtual]
Sets the font for the widget.
The fontInfo() function reports the actual font that is being used by the widget.
This code fragment sets a 12 point helvetica bold font:
QFont f("Helvetica", 12, QFont::Bold); setFont( f );
See also: font(), fontChange(), fontInfo() and fontMetrics().
Examples: xshape/xshape.cpp widgets/widgets.cpp
Reimplemented in QListBox, QComboBox and QPopupMenu.
[virtual]
Sets the widget geometry to w by h, positioned at x,y in its parent widget.
A resize event and a move event is generated immediately.
The size is adjusted if it is outside the minimum or maximum widget size.
This function is virtual, and all other overloaded setGeometry() implementations call it.
Warning: If you call setGeometry() from resizeEvent() or moveEvent(), you may see infinite recursion.
See also: geometry(), move(), resize(), moveEvent(), resizeEvent(), minimumSize() and maximumSize().
Examples: tictac/tictac.cpp drawdemo/drawdemo.cpp qmag/qmag.cpp cursor/cursor.cpp widgets/widgets.cpp
Reimplemented in QPushButton and QDialog.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it takes.
Sets the window icon pixmap.
See also: icon(), setIconText() and setCaption().
Sets the text of the window's icon to iconText.
See also: iconText(), setIcon() and setCaption().
Sets the maximum size of the widget to w by h pixels.
The widget cannot be resized to a larger size than the maximum widget size. The widget's size is forced to the maximum size if the current size is greater.
See also: maximumSize(), setMinimumSize(), setSizeIncrement(), resize() and size().
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it takes.
Sets the minimum size of the widget to w by h pixels.
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.
See also: minimumSize(), setMaximumSize(), setSizeIncrement(), resize() and size().
Examples: menu/menu.cpp qmag/qmag.cpp
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it takes.
Enables mouse tracking if enable is TRUE, or disables it if enable is FALSE.
If mouse tracking is disabled (default), this widget only receives mouse move events when at least one mouse button is pressed down while the mouse is being moved.
If mouse tracking is enabled, this widget receives mouse move events even if no buttons are pressed down.
See also: hasMouseTracking() and mouseMoveEvent().
Examples: qmag/qmag.cpp
[virtual]
Sets the widget palette to p. The widget background color is set to
colorGroup().background()
.
See also: palette(), paletteChange(), colorGroup() and setBackgroundColor().
Examples: widgets/widgets.cpp
Reimplemented in QTableView and QComboBox.
Sets the size increment of the widget. When the user resizes the window, the size will move in steps of w pixels horizontally and h pixels vertically.
Note that while you can set the size increment for all widgets, it has no effect except for top-level widgets.
Warning: The size increment has no effect under Windows.
See also: sizeIncrement(), setMinimumSize(), setMaximumSize(), resize() and size().
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it takes.
[virtual]
Sets the GUI style for this widget. The valid values are listed in qwindefs.h.
See also: style(), styleChange() and QApplication::setStyle().
Enables widget updates if enable is TRUE, or disables widget updates if enable is FALSE.
Calling update() and repaint() has no effect if updates are disabled. Paint events from the window system are processed as normally even if updates are disabled.
This function is normally used to disable updates for a short period of time, for instance to avoid screen flicker during large changes.
Example:
setUpdatesEnabled( FALSE ); bigVisualChanges(); setUpdatesEnabled( TRUE ); repaint();
See also: isUpdatesEnabled(), update(), repaint() and paintEvent().
[protected]
For internal use only.
[virtual]
Shows the widget and its child widgets.
See also: hide(), iconify() and isVisible().
Examples: xshape/xshape.cpp forever/forever.cpp connect/connect.cpp drawdemo/drawdemo.cpp picture/showpic.cpp menu/menu.cpp qmag/qmag.cpp cursor/cursor.cpp
Reimplemented in QTableView, QPopupMenu, QMenuBar and QDialog.
Returns the size of the widget, excluding the window frame.
See also: geometry(), width() and height().
[virtual]
Returns a recommended size for the widget, or an invalid size if no size is recommended.
The default implementation returns an invalid size.
See also: QSize:isValid(), resize() and setMinimumSize().
Reimplemented in QCheckBox, QComboBox, QPushButton, QRadioButton and QLabel.
Returns the widget size increment.
See also: setSizeIncrement(), minimumSize() and maximumSize().
Returns the GUI style for this widget.
See also: setStyle() and QApplication::style().
[virtual protected]
This virtual function is called from setStyle(). oldStyle is the previous style; you can get the new style from style().
Reimplement this function if your widget needs to know when its GUI style changes. You will almost certainly need to update the widget using either repaint(TRUE) or update().
The default implementation calls update().
See also: setStyle(), style(), repaint() and update().
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.
Returns the top-level widget for this widget.
A top-level widget is an overlapping widget. It usually has no parent. Modal dialog widgets are the only top-level widgets that can have parent widgets.
See also: isTopLevel().
Updates a rectangle (x, y, w, h) inside the widget unless updates are disabled or the widget is hidden.
Updating the widget erases the widget area (x,y,w,h), which in turn generates a paint event from the window system. The paint event is processed after the program has returned to the main event loop.
If w is negative, it is replaced with width() - x
.
If h is negative, it is replaced width height() - y
.
See also: repaint(), paintEvent(), setUpdatesEnabled() and erase().
Examples: drawdemo/drawdemo.cpp
Updates the widget unless updates are disabled or the widget is hidden.
Updating the widget will erase the widget contents and generate a paint event from the window system. The paint event is processed after the program has returned to the main event loop.
See also: repaint(), paintEvent(), setUpdatesEnabled() and erase().
Examples: connect/connect.cpp picture/showpic.cpp aclock/aclock.cpp
Returns the width of the widget, excluding the window frame.
See also: geometry(), height() and size().
Examples: xshape/xshape.cpp drawdemo/drawdemo.cpp aclock/aclock.cpp menu/menu.cpp showimg/showimg.cpp qmag/qmag.cpp widgets/widgets.cpp
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().
Examples: xshape/xshape.cpp
[static]
For internal use only.
Returns the x coordinate of the widget, relative to its parent widget and including the window frame.
See also: frameGeometry(), y() and pos().
Returns the y coordinate of the widget, relative to its parent widget and including the window frame.
See also: frameGeometry(), x() and pos().
Examples: drawdemo/drawdemo.cpp
This file is part of the Qt toolkit, copyright © 1995-96 Troll Tech, all rights reserved.
It was generated from the following files: