QFrame(3qt)

NAME
QFrame - The base class of widgets that can have a frame

#include <qframe.h>

Inherits QWidget.

Inherited by QGrid, QGroupBox, QHBox, QLCDNumber, QLabel, QMenuBar, QPopupMenu, QProgressBar, QScrollView, QSpinBox, QSplitter, QTableView and QWidgetStack.

  Public Members
QFrame ( QWidget * parent=0, const char * name=0, WFlags f=0, bool = TRUE )
int frameStyle () const
virtual void setFrameStyle ( int )
int frameWidth () const
QRect contentsRect () const
enum Shape { NoFrame = 0, Box = 0x0001, Panel = 0x0002, WinPanel = 0x0003, HLine = 0x0004, VLine = 0x0005, StyledPanel = 0x0006, PopupPanel = 0x0007, MShape = 0x000f }
enum Shadow { Plain = 0x0010, Raised = 0x0020, Sunken = 0x0030, MShadow = 0x00f0 }
Shape frameShape () const
void setFrameShape ( Shape )
Shadow frameShadow () const
void setFrameShadow ( Shadow )
int lineWidth () const
virtual void setLineWidth ( int )
int margin () const
virtual void setMargin ( int )
int midLineWidth () const
virtual void setMidLineWidth ( int )
QRect frameRect () const
virtual void setFrameRect ( const QRect & )

  Protected Members
virtual void paintEvent ( QPaintEvent * )
virtual void resizeEvent ( QResizeEvent * )
virtual void drawFrame ( QPainter * )
virtual void drawContents ( QPainter * )
virtual void frameChanged ()
virtual void updateMask ()
virtual void drawFrameMask ( QPainter * )
virtual void drawContentsMask ( QPainter * )

  Properties
Type | Name | READ | WRITE | Options
int | frameWidth | frameWidth
QRect | contentsRect | contentsRect
Shape | frameShape | frameShape | setFrameShape
Shadow | frameShadow | frameShadow | setFrameShadow
int | lineWidth | lineWidth | setLineWidth
int | margin | margin | setMargin
int | midLineWidth | midLineWidth | setMidLineWidth
QRect | frameRect | frameRect | setFrameRect

DESCRIPTION
The QFrame class is the base class of widgets that can have a frame.

It draws a frame and calls a virtual function, drawContents(), to fill in the frame. This function is reimplemented by subclasses. There are also two other less useful functions, drawFrame() and frameChanged().

QPopupMenu uses this to "raise" the menu above the surrounding screen. QProgressBar has a "sunken" look. QLabel has a flat look. The frames of widgets such as these can be changed.

    QLabel label(...);
    label.setFrameStyle( QFrame::Panel | QFrame::Raised );
    label.setLineWidth( 2 );
    QProgressBar pbar(...);
    label.setFrameStyle( QFrame::NoFrame );

The QFrame class can also be used directly for creating simple frames without any contents, although usually you would use a QHBox or QVBox as these layout the widgets you put inside the frame.

A frame widget has four attributes: frameStyle(), lineWidth(), midLineWidth(), and margin().

The frame style is specified by a frame shape and a shadow style. The frame shapes are NoFrame, Box, Panel, StyledPanel, PopupPanel, WinPanel, HLine and VLine, and the shadow styles are Plain, Raised and Sunken.

The line width is the width of the frame border.

The mid-line width specifies the width of an extra line in the middle of the frame, that uses a third color to obtain a special 3D effect. Notice that a mid-line is only drawn for Box, HLine and VLine frames that are raised or sunken.

The margin is the gap between the frame and the contents of the frame.

This table shows the most useful combinations of styles and widths (and some rather useless ones):

[Image Omitted]

Examples: popup/popup.cpp scrollview/scrollview.cpp movies/main.cpp

  Member Type Documentation

QFrame::Shadow
This enum type defines the 3D effect used for QFrame's frame. The currently defined effects are:

Plain - the frame and contents appear level with the surroundings

Raised - the frame and contents appear raised

Sunken - the frame and contents appear sunken

Shadow interacts with QFrame::Shape, the lineWidth() and the midLineWidth(). The picture of the frames in the class documentation may illustrate this better than words.

See also QFrame::Shape, lineWidth() and midLineWidth().

QFrame::Shape
This enum type defines the shapes of a QFrame's frame. The currently defined shapes are:

NoFrame - QFrame draws nothing

Box - QFrame draws a box around its contents

Panel - QFrame draws a panel such that the contents appear raised or sunken

WinPanel - like Panel, but QFrame draws the 3D effects the way Microsoft Windows 95 (etc) does

HLine - QFrame draws a horizontal line that frames nothing (useful as separator)

VLine - QFrame draws a vertical line that frames nothing (useful as separator)

StyledPanel - QFrame calls QStyle::drawPanel()

PopupPanel - QFrame calls QStyle::drawPopupPanel()

When it does not call QStyle, Shape interacts with QFrame::Shadow, the lineWidth() and the midLineWidth() to create the total result. The picture of the frames in the class documentation may illustrate this better than words.

See also QFrame::Shadow, QFrame::style(), QStyle::drawPanel() and QStyle::drawPopupPanel().

MEMBER FUNCTION DOCUMENTATION

QFrame::QFrame ( QWidget * parent=0, const char * name=0, WFlags f=0, bool = TRUE )
Constructs a frame widget with frame style NoFrame and a 1 pixel frame width.

The last argument exists for compatibility with Qt 1.x; it no longer has any meaning.

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

QRect QFrame::contentsRect () const
Returns the rectangle inside the frame.

See also frameRect() and drawContents().

void QFrame::drawContents ( QPainter * ) [virtual protected]
Virtual function that draws the contents of the frame.

The QPainter is already open when you get it, and you must leave it open. Painter transformations are switched off on entry. If you transform the painter, remember to take the frame into account and reset transformation before returning.

This function is reimplemented by subclasses that draw something inside the frame. It should draw only inside contentsRect(). The default function does nothing.

See also contentsRect(), QPainter::setClipRect() and drawContentsMask().

Reimplemented in QLCDNumber, QMenuBar, QLabel, QProgressBar and QPopupMenu.

void QFrame::drawContentsMask ( QPainter * p ) [virtual protected]
Virtual function that draws the mask of the frame's contents.

If you reimplemented drawContents(QPainter*) and your widget should support transparency you probably have to re-implement this function as well.

The default implementation masks the contents-rect.

See also drawContents(), updateMask(), QWidget::setAutoMask(), contentsRect() and QPainter::setClipRect().

Reimplemented in QProgressBar and QLabel.

void QFrame::drawFrame ( QPainter * p ) [virtual protected]
Draws the frame using the current frame attributes and color group. The rectangle inside the frame is not affected.

This function is virtual, but in general you do not need to reimplement it. If you do, note that the QPainter is already open and must remain open.

See also frameRect(), contentsRect(), drawContents(), frameStyle(), setPalette() and drawFrameMask().

void QFrame::drawFrameMask ( QPainter * p ) [virtual protected]
Virtual function that draws the mask of the frame's frame.

If you reimplemented drawFrame(QPainter*) and your widget should support transparency you probably have to re-implement this function as well.

See also drawFrame(), updateMask(), QWidget::setAutoMask() and QPainter::setClipRect().

void QFrame::frameChanged () [virtual protected]
Virtual function that is called when the frame style, line width or mid-line width changes.

This function can be reimplemented by subclasses that need to know when the frame attributes change.

The default implementation calls update().

Reimplemented in QHBox, QScrollView, QGrid and QWidgetStack.

QRect QFrame::frameRect () const
Returns the frame rectangle.

The default frame rectangle is equivalent to the widget rectangle.

See also setFrameRect().

Shadow QFrame::frameShadow () const
Returns the frame shadow value from the frame style.

See also setFrameShadow(), frameStyle() and frameShape().

Shape QFrame::frameShape () const
Returns the frame shape value from the frame style.

See also setFrameShape(), frameStyle() and frameShadow().

int QFrame::frameStyle () const
Returns the frame style.

The default value is QFrame::NoFrame.

See also setFrameStyle(), frameShape() and frameShadow().

Examples: scrollview/scrollview.cpp

int QFrame::frameWidth () const
Returns the width of the frame that is drawn.

Note that the frame width depends on the frame style, not only the line width and the mid line width. For example, the style NoFrame always has a frame width 0, while the style Panel has a frame width equivalent to the line width. The frame width also includes the margin.

See also lineWidth(), midLineWidth(), frameStyle() and margin().

int QFrame::lineWidth () const
Returns the line width. (Note that the total line width for HLine and VLine is given by frameWidth(), not lineWidth().)

The default value is 1.

See also setLineWidth(), midLineWidth() and frameWidth().

Examples: scrollview/scrollview.cpp

int QFrame::margin () const
Returns the width of the margin. The margin is the distance between the innermost pixel of the frame and the outermost pixel of contentsRect(). It is included in frameWidth().

The margin is filled according to backgroundMode().

The default value is 0.

See also setMargin(), lineWidth() and frameWidth().

Examples: scrollview/scrollview.cpp

int QFrame::midLineWidth () const
Returns the width of the mid-line.

The default value is 0.

See also setMidLineWidth(), lineWidth() and frameWidth().

Examples: scrollview/scrollview.cpp

void QFrame::paintEvent ( QPaintEvent * event ) [virtual protected]
Handles paint events for the frame.

Paints the frame and the contents.

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

Reimplemented from QWidget.

void QFrame::resizeEvent ( QResizeEvent * e ) [virtual protected]
Handles resize events for the frame.

Adjusts the frame rectangle for the resized widget. The frame rectangle is elastic, the surrounding area is static.

The resulting frame rectangle may be null or invalid. You can use setMinimumSize() to avoid that possibility.

Nothing is done if the frame rectangle is a null rectangle already.

Reimplemented from QWidget.

void QFrame::setFrameRect ( const QRect & r ) [virtual]
Sets the frame rectangle to r.

The frame rectangle is the rectangle the frame is drawn in. By default, this is the entire widget. Calling setFrameRect() does not cause a widget update.

If r is a null rectangle (for example QRect(0,0,0,0)), then the frame rectangle is equivalent to the widget rectangle.

See also frameRect() and contentsRect().

Reimplemented in QWidgetStack.

void QFrame::setFrameShadow ( Shadow )
Sets the frame shadow value of the frame style.

See also frameShadow(), frameStyle() and setFrameShape().

void QFrame::setFrameShape ( Shape )
Sets the frame shape value of the frame style.

See also frameShape(), frameStyle() and setFrameShadow().

void QFrame::setFrameStyle ( int style ) [virtual]
Sets the frame style to style.

The style is the bitwise OR between a frame shape and a frame shadow style. See the illustration in the class documentation.

The frame shapes are:

NoFrame draws nothing. Naturally, you should not specify a shadow style if you use this.

Box draws a rectangular box. The contents appear to be level with the surrounding screen, but the border itself may be raised or sunken.

Panel draws a rectangular panel that can be raised or sunken.

StyledPanel draws a rectangular panel with a look depending on the current GUI style. It can be raised or sunken.

PopupPanel is used to draw a frame suitable for popup windows. Its look also depends on the current GUI style, usually the same as StyledPanel.

WinPanel draws a rectangular panel that can be raised or sunken, very like those in Windows 95. Specifying this shape sets the line width to 2 pixels. WinPanel is provided for compatibility. For GUI style independence we recommend using StyledPanel instead.

HLine draws a horizontal line (vertically centered).

VLine draws a vertical line (horizontally centered).

The shadow styles are:

Plain draws using the palette foreground color (without any 3D effect).

Raised draws a 3D raised line using the light and dark colors of the current color group.

Sunken draws a 3D sunken line using the light and dark colors of the current color group.

If a mid-line width greater than 0 is specified, an additional line is drawn for Raised or Sunken Box, HLine and VLine frames. The mid color of the current color group is used for drawing middle lines.

See also Illustration, frameStyle(), colorGroup() and QColorGroup.

Examples: xform/xform.cpp cursor/cursor.cpp layout/layout.cpp popup/popup.cpp scrollview/scrollview.cpp customlayout/main.cpp

void QFrame::setLineWidth ( int w ) [virtual]
Sets the line width to w.

See also frameWidth(), lineWidth() and setMidLineWidth().

Examples: xform/xform.cpp scrollview/scrollview.cpp

void QFrame::setMargin ( int w ) [virtual]
Sets the width of the margin to w.

See also margin() and setLineWidth().

Examples: scrollview/scrollview.cpp

void QFrame::setMidLineWidth ( int w ) [virtual]
Sets the width of the mid-line to w.

See also midLineWidth() and setLineWidth().

Examples: scrollview/scrollview.cpp

QSize QFrame::sizeHint () const [virtual]
Reimplemented for internal reasons; the API is not affected.

Reimplemented from QWidget.

QSizePolicy QFrame::sizePolicy () const [virtual]
Reimplemented for internal reasons; the API is not affected.

Reimplemented from QWidget.

void QFrame::updateMask () [virtual protected]
Reimplementation of QWidget::updateMask(). Draws the mask of the frame when transparency is required.

This function calls the virtual functions drawFrameMask() and drawContentsMask(). These are the ones you may want to reimplement in subclasses.

See also QWidget::setAutoMask(), drawFrameMask() and drawContentsMask().

Reimplemented from QWidget.

SEE ALSO
http://doc.trolltech.com/qframe.html http://www.trolltech.com/faq/tech.html

COPYRIGHT
Copyright 1992-2001 Trolltech AS, http://www.trolltech.com. See the license file included in the distribution for a complete license statement.

AUTHOR
Generated automatically from the source code.

BUGS
If you find a bug in Qt, please report it as described in http://doc.trolltech.com/bughowto.html. Good bug reports make our job much simpler. Thank you.

In case of content or formattting problems with this manual page, please report them to qt-bugs@trolltech.com. Please include the name of the manual page (qframe.3qt) and the Qt version (2.3.7).