Home | All Classes | Main Classes | Annotated | Grouped Classes | Functions |

# QFrame Class Reference

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

    #include <QFrame>

Inherits QWidget.

Inherited by Q3Frame, QScrollView, QWidgetStack, QDockWindow, QGridWidget, QHBoxWidget, QLabel, QLCDNumber, QProgressBar, QSplitter, QStackedBox, QToolBar, QToolBox, and QViewport.

- List of all members, including inherited members
- Compatibility members

### Public Types

- enum Shadow { Plain, Raised, Sunken }
- enum Shape { NoFrame, Box, Panel, StyledPanel, HLine, ..., WinPanel }

### Writable Properties

- frameRect : QRect
- frameShadow : Shadow
- frameShape : Shape

- lineWidth : int
- midLineWidth : int

- 33 writable properties inherited from QWidget
- 1 writable property inherited from QObject

### Read-Only Properties

- frameWidth : int

- 24 read-only properties inherited from QWidget

### Public Functions

- QFrame ( QWidget * parent = 0, Qt::WFlags f = 0 )
- ~QFrame ()
- int frameStyle () const
- void setFrameStyle ( int style )

- 83 public functions inherited from QWidget
- 24 public functions inherited from QObject
- 2 public functions inherited from QPaintDevice

### Public Slots

- 16 public slots inherited from QWidget
- 1 public slot inherited from QObject

### Signals

- 1 signal inherited from QObject

### Static Public Members

- 4 static public members inherited from QWidget
- 4 static public members inherited from QObject

### Protected Functions

- 44 protected functions inherited from QWidget
- 9 protected functions inherited from QObject

## Detailed Description

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

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 like 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 because they automatically lay out 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`, HLine and `VLine`; 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, which 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):

## Member Type Documentation

### enum QFrame::Shadow

This enum type defines the 3D effect used for QFrame's frame.

`QFrame::Plain` | the frame and contents appear level with the surroundings; draws using the palette foreground color (without any 3D effect)
`QFrame::Raised` | the frame and contents appear raised; draws a 3D raised line using the light and dark colors of the current color group
`QFrame::Sunken` | the frame and contents appear sunken; draws a 3D sunken line using the light and dark colors of the current color group

Shadow interacts with QFrame::Shape, the lineWidth() and the midLineWidth(). See the picture of the frames in the class description.

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

### enum QFrame::Shape

This enum type defines the shapes of a QFrame's frame.

`QFrame::NoFrame` | QFrame draws nothing
`QFrame::Box` | QFrame draws a box around its contents
`QFrame::Panel` | QFrame draws a panel to make the contents appear raised or sunken
`QFrame::StyledPanel` | draws a rectangular panel with a look that depends on the current GUI style. It can be raised or sunken.
`QFrame::HLine` | QFrame draws a horizontal line that frames nothing (useful as separator)
`QFrame::VLine` | QFrame draws a vertical line that frames nothing (useful as separator)
`QFrame::WinPanel` | draws a rectangular panel that can be raised or sunken 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.

When it does not call QStyle, Shape interacts with QFrame::Shadow, the lineWidth() and the midLineWidth() to create the total result. See the picture of the frames in the class description.

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

## Property Documentation

### frameRect : QRect

This property holds the frame's rectangle.

The frame's rectangle is the rectangle the frame is drawn in. By default, this is the entire widget. Setting the rectangle does does not cause a widget update. The frame rectangle is automatically adjusted when the widget changes size.

If you set the rectangle to a null rectangle (for example `QRect(0, 0, 0, 0)`), then the resulting frame rectangle is equivalent to the widget rectangle.

Access functions:

- QRect frameRect () const
- void setFrameRect ( const QRect & )

### frameShadow : Shadow

This property holds the frame shadow value from the frame style.

Access functions:

- Shadow frameShadow () const
- void setFrameShadow ( Shadow )

See also frameStyle() and frameShape().

### frameShape : Shape

This property holds the frame shape value from the frame style.

Access functions:

- Shape frameShape () const
- void setFrameShape ( Shape )

See also frameStyle() and frameShadow().

### frameWidth : int

This property holds 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 of 0, whereas the style `Panel` has a frame width equivalent to the line width.

Access functions:

- int frameWidth () const

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

### lineWidth : int

This property holds the line width.

Note that the total line width for `HLine` and `VLine` is specified by frameWidth(), not lineWidth().

The default value is 1.

Access functions:

- int lineWidth () const
- void setLineWidth ( int )

See also midLineWidth() and frameWidth().

### midLineWidth : int

This property holds the width of the mid-line.

The default value is 0.

Access functions:

- int midLineWidth () const
- void setMidLineWidth ( int )

See also lineWidth() and frameWidth().

## Member Function Documentation

### QFrame::QFrame ( QWidget * parent = 0, Qt::WFlags f = 0 )

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

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

### QFrame::~QFrame ()

Destroys the frame.

### int QFrame::frameStyle () const

Returns the frame style.

The default value is QFrame::NoFrame.

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

### void QFrame::setFrameStyle ( int style )

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 given in QFrame::Shape and the shadow styles in QFrame::Shadow.

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