QFrame Class Reference


The QFrame class is the base class of widgets that have an (optional) frame. (details) (complete member list)

#include <qframe.h>

Inherits QWidget.

Inherited by QGroupBox, QLCDNumber, QLabel and QTableWidget.

Public Members

Protected Members


Detailed Description

The QFrame class is the base class of widgets that have an (optional) frame.

The QLabel and QGroupBox widgets are examples of widgets that inherit QFrame to allow frames around these widgets. The QFrame class can also be used directly for creating simple frames without any contents.

A frame widget has a frame type, a frame style a frame width and a mid-line width.

The different frame types are NoFrame, Box, Panel, HLine and VLine. Notice that the two latter ones specify lines, not rectangles.

The frame styles are Plain, Raised and Sunken. See setFrameStyle() for a description of frame types and frame styles.

The frame width is the width of the frame border.

The mid-line width specifies the width of an extra line in the middle of the border, that uses a third color to get a special 3D effect.

Example of use:

  QFrame *f = new QFrame;
  f->setFrameStyle( QFrame::Panel | QFrame::Sunken );

Member Function Documentation

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

Constructs a frame widget with frame style NoFrame and 1 pixel frame width.

The parent and name arguments are passed to the QWidget constructor.

QRect QFrame::contentsRect () const

Returns the geometry of the rectangle inside the frame.

See also: frameRect().

void QFrame::drawContents (QPainter *p)

Virtual function that draws the contents of the frame.

This function is reimplemented by subclasses that want to draw something inside the frame.

void QFrame::drawFrame (QPainter *p)

Internal function that draws the frame.

QRect QFrame::frameRect () const

Returns the frame rectangle.

See also: setFrameRect()

int QFrame::frameStyle () const

Returns the frame type and style.

See also: setFrameStyle().

int QFrame::frameWidth () const

Returns the width of the frame that is drawn.

int QFrame::lineWidth () const

Returns the line width.

See also: setFrameWidth().

int QFrame::midLineWidth () const

Returns the width of the middle line.

See also: setMidLineWidth()

void QFrame::paintEvent (QPaintEvent *)

Paints the frame.

Opens the painter on the frame and calls first drawFrame(), then drawContents().

void QFrame::setFrameRect (const QRect &r)

Sets the frame rectangle to r.

If r is a null rectangle (for example QRect(0,0,0,0)), then the frame rectangle follows the widget rectangle (QWidget::rect()).

See also: frameRect().

void QFrame::setFrameStyle (int style)

Sets the frame style to style.

The style is the bitwise OR between a frame geometry style and a frame shadow style.

The geometry styles are:

The shadow styles are:

Raised and Sunken will draw an additional middle line if a mid-line width greater than 0 was specified. The palette mid color is used for drawing middle lines.

See also: frameStyle(), QPalette.

void QFrame::setLineWidth (int fw)

Sets the frame width to fw.

See also: lineWidth()

void QFrame::setMidLineWidth (int mw)

Sets the width of the middle line to mw.

See also: midLineWidth().


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