Movatterモバイル変換


[0]ホーム

URL:


We bake cookies in your browser for a better experience. Using this site means that you consent.Read More

Menu

Qt Documentation

QFrame Class

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

Public Types

enumShadow { Plain, Raised, Sunken }
enumShape { NoFrame, Box, Panel, StyledPanel, ..., WinPanel }
enumStyleMask { Shadow_Mask, Shape_Mask }

Properties

Public Functions

QFrame(QWidget * parent = 0, Qt::WindowFlags f = 0)
~QFrame()
QRectframeRect() const
ShadowframeShadow() const
ShapeframeShape() const
intframeStyle() const
intframeWidth() const
intlineWidth() const
intmidLineWidth() const
voidsetFrameRect(const QRect &)
voidsetFrameShadow(Shadow)
voidsetFrameShape(Shape)
voidsetFrameStyle(int style)
voidsetLineWidth(int)
voidsetMidLineWidth(int)

Reimplemented Public Functions

virtual QSizesizeHint() const

Reimplemented Protected Functions

virtual voidchangeEvent(QEvent * ev)
virtual boolevent(QEvent * e)
virtual voidpaintEvent(QPaintEvent *)
  • 37 protected functions inherited fromQWidget
  • 8 protected functions inherited fromQObject
  • 1 protected function inherited fromQPaintDevice

Additional Inherited Members

  • 19 public slots inherited fromQWidget
  • 1 public slot inherited fromQObject
  • 1 signal inherited fromQWidget
  • 1 signal inherited fromQObject
  • 4 static public members inherited fromQWidget
  • 7 static public members inherited fromQObject
  • 37 protected functions inherited fromQWidget
  • 8 protected functions inherited fromQObject
  • 1 protected function inherited fromQPaintDevice
  • 1 protected slot inherited fromQWidget

Detailed Description

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

QMenu 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);

TheQFrame class can also be used directly for creating simple placeholder frames without any contents.

The frame style is specified by aframe shape and ashadow style that is used to visually separate the frame from surrounding widgets. These properties can be set together using thesetFrameStyle() function and read withframeStyle().

The frame shapes areNoFrame,Box,Panel,StyledPanel,HLine andVLine; the shadow styles arePlain,Raised andSunken.

A frame widget has three attributes that describe the thickness of the border:lineWidth,midLineWidth, andframeWidth.

  • 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 forBox,HLine andVLine frames that are raised or sunken.
  • The frame width is determined by the frame style, and theframeWidth() 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 theQWidget::setContentsMargins() function.

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

Table of frame styles

Member Type Documentation

enum QFrame::Shadow

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

ConstantValueDescription
QFrame::Plain0x0010the frame and contents appear level with the surroundings; draws using the paletteQPalette::WindowText color (without any 3D effect)
QFrame::Raised0x0020the frame and contents appear raised; draws a 3D raised line using the light and dark colors of the current color group
QFrame::Sunken0x0030the frame and contents appear sunken; draws a 3D sunken line using the light and dark colors of the current color group

Shadow interacts withQFrame::Shape, thelineWidth() and themidLineWidth(). See the picture of the frames in the main class documentation.

See alsoQFrame::Shape,lineWidth(), andmidLineWidth().

enum QFrame::Shape

This enum type defines the shapes of frame available.

ConstantValueDescription
QFrame::NoFrame0QFrame draws nothing
QFrame::Box0x0001QFrame draws a box around its contents
QFrame::Panel0x0002QFrame draws a panel to make the contents appear raised or sunken
QFrame::StyledPanel0x0006draws a rectangular panel with a look that depends on the current GUI style. It can be raised or sunken.
QFrame::HLine0x0004QFrame draws a horizontal line that frames nothing (useful as separator)
QFrame::VLine0x0005QFrame draws a vertical line that frames nothing (useful as separator)
QFrame::WinPanel0x0003draws 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 callQStyle, Shape interacts withQFrame::Shadow, thelineWidth() and themidLineWidth() to create the total result. See the picture of the frames in the main class documentation.

See alsoQFrame::Shadow,QFrame::style(), andQStyle::drawPrimitive().

enum QFrame::StyleMask

This enum defines two constants that can be used to extract the two components offrameStyle():

ConstantValueDescription
QFrame::Shadow_Mask0x00f0TheShadow part offrameStyle()
QFrame::Shape_Mask0x000fTheShape part offrameStyle()

Normally, you don't need to use these, sinceframeShadow() andframeShape() already extract theShadow and theShape parts offrameStyle().

See alsoframeStyle() andsetFrameStyle().

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 doesnot 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 thewidget rectangle.

Access functions:

QRectframeRect() const
voidsetFrameRect(const QRect &)

frameShadow :Shadow

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

Access functions:

ShadowframeShadow() const
voidsetFrameShadow(Shadow)

See alsoframeStyle() andframeShape().

frameShape :Shape

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

Access functions:

ShapeframeShape() const
voidsetFrameShape(Shape)

See alsoframeStyle() andframeShadow().

frameWidth : constint

This property holds the width of the frame that is drawn.

Note that the frame width depends on theframe style, not only the line width and the mid-line width. For example, the style specified byNoFrame always has a frame width of 0, whereas the stylePanel has a frame width equivalent to the line width.

Access functions:

intframeWidth() const

See alsolineWidth(),midLineWidth(), andframeStyle().

lineWidth :int

This property holds the line width.

Note that thetotal line width for frames used as separators (HLine andVLine) is specified byframeWidth.

The default value is 1.

Access functions:

intlineWidth() const
voidsetLineWidth(int)

See alsomidLineWidth andframeWidth.

midLineWidth :int

This property holds the width of the mid-line.

The default value is 0.

Access functions:

intmidLineWidth() const
voidsetMidLineWidth(int)

See alsolineWidth andframeWidth.

Member Function Documentation

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

Constructs a frame widget with frame styleNoFrame and a 1-pixel frame width.

Theparent andf arguments are passed to theQWidget constructor.

QFrame::~QFrame()

Destroys the frame.

[virtual protected]void QFrame::changeEvent(QEvent * ev)

Reimplemented fromQWidget::changeEvent().

[virtual protected]bool QFrame::event(QEvent * e)

Reimplemented fromQObject::event().

int QFrame::frameStyle() const

Returns the frame style.

The default value isQFrame::Plain.

See alsosetFrameStyle(),frameShape(), andframeShadow().

[virtual protected]void QFrame::paintEvent(QPaintEvent *)

Reimplemented fromQWidget::paintEvent().

void QFrame::setFrameStyle(int style)

Sets the frame style tostyle.

Thestyle 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 inQFrame::Shape and the shadow styles inQFrame::Shadow.

If a mid-line width greater than 0 is specified, an additional line is drawn forRaised orSunkenBox,HLine, andVLine frames. The mid-color of the current color group is used for drawing middle lines.

See alsoframeStyle().

[virtual]QSize QFrame::sizeHint() const

Reimplemented fromQWidget::sizeHint().

© 2016 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of theGNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.


[8]ページ先頭

©2009-2025 Movatter.jp