QWidget Class Reference


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.

Public Members

Signals

Static Public Members

Protected Members


Detailed Description

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

Lots of verbiage here...


Member Function Documentation

QWidget::QWidget (QWidget *parent=0, const char *name=0, WFlags f=0)

Constructs a new QWidget inside parent, named name, optionally with widget flags f.

The widget flags are strictly internal and likely to change before 1.0. You are strongly advised to use 0.

If parent is 0, the new widget will be a top level window.

The widget name is not used in this version of Qt, it is reserved for future use.

QWidget::~QWidget ()

Destroys the widget. All children of this widget are deleted first. The application exits if this widget is (was) the main widget.

void QWidget::closeEvent (QCloseEvent *e)

This function is virtual and does nothing by default.

See also: event()

QCursor QWidget::cursor () const

Returns the widget cursor shape.

See also: setCursor().

void QWidget::destroyed ()

This signal is emitted immediately before the widget is destroyed.

All the widget's children will be destroyed before the signal is emitted.

void QWidget::drawText (const QPoint &p, const char *s)

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.

void QWidget::drawText (int x, int y, const char *str)

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.

void QWidget::focusInEvent (QFocusEvent *)

This function is virtual and does nothing by default.

See also: event()

void QWidget::focusOutEvent (QFocusEvent *)

This function is virtual and does nothing by default.

See also: event()

QFont & QWidget::font ()

Returns the font currently set for the widget.

QFontInfo will tell you what font is actually being used.

See also: setFont(), fontMetrics() and fontInfo().

QFontInfo QWidget::fontInfo () const

Returns the font information of the font currently in use by this widget.

See also: fontMetrics(), font() and setFont().

QFontMetrics QWidget::fontMetrics () const

Returns the font metrics of the font currently in use by this widget.

See also: fontInfo(), font() and setFont().

QRect QWidget::frameGeometry () const

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

QRect QWidget::geometry () const

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

void QWidget::grabKeyboard ()

Grabs the keyboard input focus.

This widget will receive all keyboard events, no matter where the mouse cursor is.

See also: releaseKeyboard(), grabMouse(), releaseMouse().

void QWidget::grabMouse ()

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

void QWidget::grabMouse (const QCursor &cursor)

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

bool QWidget::hasFocus () const

Returns TRUE if the widget (not one of its children) has the keyboard focus.

int QWidget::height () const

Returns the height of the widget, excluding any window frames.

See also: size() and width().

WId QWidget::id () 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.

See also: find().

bool QWidget::isDisabled () const

Returns TRUE if the widget is disabled, or FALSE if it is enabled.

See also: enable() and disable().

bool QWidget::isVisible () const

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.

void QWidget::keyPressEvent (QKeyEvent *e)

This function is virtual and does nothing by default.

See also: event()

void QWidget::keyReleaseEvent (QKeyEvent *e)

This function is virtual and does nothing by default.

See also: event()

QPoint QWidget::mapFromGlobal (const QPoint &pos) const

Translates the global screen coordinate pos to widget coordinates.

See also: mapToGlobal().

QPoint QWidget::mapFromParent (const QPoint &p) const

Translates the parent widget coordinate pos to widget coordinates.

Same as mapFromGlobal() if the widget has no parent.

See also: mapToParent().

QPoint QWidget::mapToGlobal (const QPoint &pos) const

Translates the widget coordinate pos to global screen coordinates.

See also: mapFromGlobal().

QPoint QWidget::mapToParent (const QPoint &p) 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().

void QWidget::mouseDoubleClickEvent (QMouseEvent *e)

This function is virtual and translates to a single click by default.

See also: event()

void QWidget::mouseMoveEvent (QMouseEvent *)

This function is virtual and does nothing by default.

See also: event()

void QWidget::mousePressEvent (QMouseEvent *)

This function is virtual and does nothing by default.

See also: event()

void QWidget::mouseReleaseEvent (QMouseEvent *)

This function is virtual and does nothing by default.

See also: event()

void QWidget::move (const QPoint &p)

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

void QWidget::moveEvent (QMoveEvent *)

This function is virtual and does nothing by default.

See also: event()

void QWidget::paintEvent (QPaintEvent *)

This function is virtual and does nothing by default.

See also: event()

QWidget * QWidget::parentWidget () const

Returns a pointer to the parent of this widget, or a null pointer if it does not have any parent widget.

QPoint QWidget::pos () const

Returns the postion of the widget in its parent widget, excluding frames and other decorations.

See also: frameGeometry(), x() and y().

void QWidget::recreate (QWidget *parent, WFlags f, const QPoint &p, bool showIt=FALSE)

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.

QRect QWidget::rect () const

Returns the the internal geometry of the widget, excluding any window frames. rect() equals QRect(0,0,width(),height()).

See also: size().

void QWidget::releaseKeyboard ()

Releases the keyboard focus. The keyboard events will follow their natural inclination.

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

void QWidget::releaseMouse ()

Releases the mouse from a grab.

See also: grabMouse().

void QWidget::repaint (const QRect &r, bool eraseArea=TRUE)

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.

void QWidget::resize (const QSize & p)

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

void QWidget::resizeEvent (QResizeEvent *)

This function is virtual and does nothing by default.

See also: event()

void QWidget::setAcceptFocus (bool enable)

Enables or disables the keyboard input focus events for the widget.

Focus events are initially disabled.

void QWidget::setBackgroundColor (const QColor &c)

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

void QWidget::setBackgroundPixmap (const QPixmap &pm)

Sets the background pixmap of the widget to pm.

The background pixmap is tiled.

void QWidget::setCursor (const QCursor &cursor)

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

void QWidget::setGeometry (const QRect &r)

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.

See also: move(), resize().

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

Changes the widget geometry to x pixels by y, positioned at w,h 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.

See also: move(), resize().

bool QWidget::setMouseTracking (bool enable)

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

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

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

QSize QWidget::size () const

Returns the size of the widget, excluding any window frames.

See also: geometry(), width() and height().

bool QWidget::testFlag (WFlags n) const

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.

void QWidget::timerEvent (QTimerEvent *)

This function is virtual and does nothing by default.

See also: event()

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

Updates a rectangle (x, y, w, h) inside the widget.

Calling update() will generate a paint event from the X server.

int QWidget::width () const

Returns the width of the widget, excluding any window frames.

See also: size() and height().

int QWidget::x () const

Returns the x coordinate of the widget, relative to its parent widget and excluding frames and other decorations.

See also: geometry(), pos() and y().

int QWidget::y () const

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:


Generated at 04:27, 1995/05/20 by the webmaster at Troll Tech