Table Of Contents

Previous topic

QSlider

Next topic

QAbstractScrollArea

QFrame

Inheritance diagram of QFrame

Inherited by: QAbstractScrollArea, QGraphicsView, QDeclarativeView, QToolBox, QStackedWidget, QSplitter, QScrollArea, QPlainTextEdit, QTextEdit, QTextBrowser, QMdiArea, QLCDNumber, QLabel, QAbstractItemView, QHeaderView, QTreeView, QHelpContentWidget, QTreeWidget, QListView, QHelpIndexWidget, QUndoView, QListWidget, QColumnView, QTableView, QTableWidget

Synopsis

Functions

Detailed Description

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

PySide.QtGui.QMenu uses this to “raise” the menu above the surrounding screen. PySide.QtGui.QProgressBar has a “sunken” look. PySide.QtGui.QLabel has a flat look. The frames of widgets like these can be changed.

label = QLabel()
label.setFrameStyle(QFrame.Panel | QFrame.Raised)
label.setLineWidth(2)

pbar = QProgressBar()
label.setFrameStyle(QFrame.NoFrame)

The PySide.QtGui.QFrame class can also be used directly for creating simple placeholder frames without any contents.

The frame style is specified by a frame shape and a shadow style that is used to visually separate the frame from surrounding widgets. These properties can be set together using the PySide.QtGui.QFrame.setFrameStyle() function and read with PySide.QtGui.QFrame.frameStyle() .

The frame shapes are NoFrame , Box , Panel , StyledPanel , HLine and VLine ; the shadow styles are Plain , Raised and Sunken .

A frame widget has three attributes that describe the thickness of the border: PySide.QtGui.QFrame.lineWidth() , PySide.QtGui.QFrame.midLineWidth() , and PySide.QtGui.QFrame.frameWidth() .

  • The line width is the width of the frame border. It can be modified to customize the frame’s appearance.
  • 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 frame width is determined by the frame style, and the PySide.QtGui.QFrame.frameWidth() function is used to obtain the value defined for the style used.

The margin between the frame and the contents of the frame can be customized with the QWidget.setContentsMargins() function.

This table shows some of the combinations of styles and line widths:

../../_images/frames.png
class PySide.QtGui.QFrame([parent=None[, f=0]])
Parameters:
PySide.QtGui.QFrame.StyleMask

This enum defines two constants that can be used to extract the two components of PySide.QtGui.QFrame.frameStyle() :

Constant Description
QFrame.Shadow_Mask The QFrame.Shadow part of PySide.QtGui.QFrame.frameStyle()
QFrame.Shape_Mask The QFrame.Shape part of PySide.QtGui.QFrame.frameStyle()

Normally, you don’t need to use these, since PySide.QtGui.QFrame.frameShadow() and PySide.QtGui.QFrame.frameShape() already extract the QFrame.Shadow and the QFrame.Shape parts of PySide.QtGui.QFrame.frameStyle() .

PySide.QtGui.QFrame.Shape

This enum type defines the shapes of frame available.

Constant Description
QFrame.NoFrame PySide.QtGui.QFrame draws nothing
QFrame.Box PySide.QtGui.QFrame draws a box around its contents
QFrame.Panel PySide.QtGui.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 PySide.QtGui.QFrame draws a horizontal line that frames nothing (useful as separator)
QFrame.VLine PySide.QtGui.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 2000. 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 PySide.QtGui.QStyle , Shape interacts with QFrame.Shadow , the PySide.QtGui.QFrame.lineWidth() and the PySide.QtGui.QFrame.midLineWidth() to create the total result. See the picture of the frames in the main class documentation.

See also

QFrame.Shadow QFrame.style() QStyle.drawPrimitive()

PySide.QtGui.QFrame.Shadow

This enum type defines the types of shadow that are used to give a 3D effect to frames.

Constant Description
QFrame.Plain the frame and contents appear level with the surroundings; draws using the palette QPalette.WindowText 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 PySide.QtGui.QFrame.lineWidth() and the PySide.QtGui.QFrame.midLineWidth() . See the picture of the frames in the main class documentation.

PySide.QtGui.QFrame.drawFrame(arg__1)
Parameters:arg__1PySide.QtGui.QPainter

Mostly for the sake of Q3Frame

PySide.QtGui.QFrame.frameRect()
Return type:PySide.QtCore.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, PySide.QtCore.QRect (0, 0, 0, 0)), then the resulting frame rectangle is equivalent to the widget rectangle .

PySide.QtGui.QFrame.frameShadow()
Return type:PySide.QtGui.QFrame.Shadow

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

PySide.QtGui.QFrame.frameShape()
Return type:PySide.QtGui.QFrame.Shape

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

PySide.QtGui.QFrame.frameStyle()
Return type:PySide.QtCore.int

Returns the frame style.

The default value is QFrame.Plain .

PySide.QtGui.QFrame.frameWidth()
Return type:PySide.QtCore.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 specified by NoFrame always has a frame width of 0, whereas the style Panel has a frame width equivalent to the line width.

PySide.QtGui.QFrame.lineWidth()
Return type:PySide.QtCore.int

This property holds the line width.

Note that the total line width for frames used as separators ( HLine and VLine ) is specified by PySide.QtGui.QFrame.frameWidth() .

The default value is 1.

PySide.QtGui.QFrame.midLineWidth()
Return type:PySide.QtCore.int

This property holds the width of the mid-line.

The default value is 0.

PySide.QtGui.QFrame.setFrameRect(arg__1)
Parameters:arg__1PySide.QtCore.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, PySide.QtCore.QRect (0, 0, 0, 0)), then the resulting frame rectangle is equivalent to the widget rectangle .

PySide.QtGui.QFrame.setFrameShadow(arg__1)
Parameters:arg__1PySide.QtGui.QFrame.Shadow

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

PySide.QtGui.QFrame.setFrameShape(arg__1)
Parameters:arg__1PySide.QtGui.QFrame.Shape

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

PySide.QtGui.QFrame.setFrameStyle(arg__1)
Parameters:arg__1PySide.QtCore.int

Sets the frame style to style .

The style is the bitwise OR between a frame shape and a frame shadow style. See the picture of the frames in the main 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.

PySide.QtGui.QFrame.setLineWidth(arg__1)
Parameters:arg__1PySide.QtCore.int

This property holds the line width.

Note that the total line width for frames used as separators ( HLine and VLine ) is specified by PySide.QtGui.QFrame.frameWidth() .

The default value is 1.

PySide.QtGui.QFrame.setMidLineWidth(arg__1)
Parameters:arg__1PySide.QtCore.int

This property holds the width of the mid-line.

The default value is 0.