QFrame(3qt)
QFrame π β the base class of widgets that can have a frame
okay bestie, pull up a chair because this is the Qt page for QFrame, from the 3qt manual. she's the blueprint, the blueprint-iest blueprint. everything that has a lil border? yeah. her. β¨
πΈ NAME πΈ
QFrame β the base class of widgets that can have a frame. that's it. that's the whole job title. and she ATE. π
β¨ SYNOPSIS β¨
#include <qframe.h>
she inherits QWidget. as she should. π
she is inherited by QGroupBox, QScrollView, QDockWindow, QGrid, QHBox, QLabel, QLCDNumber, QLineEdit, QMenuBar, QPopupMenu, QProgressBar, QSplitter, QToolBox, and QWidgetStack. that's a whole friend group fr fr π«Ά
π Public Members π
QFrame ( QWidget * parent = 0, const char * name = 0, WFlags f = 0 )int frameStyle () constvirtual void setFrameStyle ( int style )int frameWidth () constQRect contentsRect () constenum Shape { NoFrame = 0, Box = 0x0001, Panel = 0x0002, WinPanel = 0x0003, HLine = 0x0004, VLine = 0x0005, StyledPanel = 0x0006, PopupPanel = 0x0007, MenuBarPanel = 0x0008, ToolBarPanel = 0x0009, LineEditPanel = 0x000a, TabWidgetPanel = 0x000b, GroupBoxPanel = 0x000c, MShape = 0x000f }enum Shadow { Plain = 0x0010, Raised = 0x0020, Sunken = 0x0030, MShadow = 0x00f0 }Shape frameShape () constvoid setFrameShape ( Shape )Shadow frameShadow () constvoid setFrameShadow ( Shadow )int lineWidth () constvirtual void setLineWidth ( int )int margin () constvirtual void setMargin ( int )int midLineWidth () constvirtual void setMidLineWidth ( int )QRect frameRect () constvirtual void setFrameRect ( const QRect & )
π¦ Properties π¦
QRectcontentsRectβ the rectangle inside the frame (read only) πQRectframeRectβ the frame rectangleShadowframeShadowβ the frame shadow value from the frame styleShapeframeShapeβ the frame shape value from the frame styleintframeWidthβ the width of the frame that is drawn (read only) πintlineWidthβ the line widthintmarginβ the width of the marginintmidLineWidthβ the width of the mid-line
π Protected Members π
virtual void paintEvent ( QPaintEvent * event )virtual void resizeEvent ( QResizeEvent * e )virtual void drawFrame ( QPainter * p )virtual void drawContents ( QPainter * )virtual void frameChanged ()
π DESCRIPTION π
so. QFrame is the base class of widgets that can have a frame. the blueprint. the blueprint's blueprint. π§
she draws a frame, and then she calls a virtual function, drawContents(), to fill in the frame. that function gets reimplemented by subclasses β like, that's the whole point, the children do the decorating. there are also two other, lowkey less useful functions: drawFrame() and frameChanged(). not useless, just... less booked and busy. π
QPopupMenu uses this to "raise" the menu above the surrounding screen. QProgressBar has a "sunken" look. QLabel has a flat look. and the frames of widgets like these can be changed β glow up whenever you want:
QLabel label(...);
label.setFrameStyle( QFrame::Panel | QFrame::Raised );
label.setLineWidth( 2 );
QProgressBar pbar(...);
label.setFrameStyle( QFrame::NoFrame );
(and yes, that last line really does say label, not pbar, bestie. I don't make the rules. π)
QFrame can also be used directly for creating simple frames with no contents at all β no cap, she works solo too. although usually you'd use a QHBox or QVBox instead, because those automatically lay out the widgets you put inside the frame. teamwork makes the dream work π«Ά
a frame widget has four attributes: frameStyle(), lineWidth(), midLineWidth(), and margin(). four. count 'em. β¨
the frame style is specified by a frame shape and a shadow style. the frame shapes are NoFrame, Box, Panel, StyledPanel, PopupPanel, WinPanel, ToolBarPanel, MenuBarPanel, 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. so don't come crying to me when your mid-line doesn't show up on your Panel, okay? π
the margin is the gap between the frame and the contents of the frame.
there's a table that shows the most useful combinations of styles and widths (and some rather useless ones, which is honestly so real of it):
[Image Omitted] β yeah bestie the picture didn't survive the export, I'm as devastated as you are π₯²
See also Abstract Widget Classes.
π Member Type Documentation π
QFrame::Shadow
this enum type defines the 3D effect used for QFrame's frame. the drama. the dimension. the depth. π
QFrame::Plainβ the frame and contents appear level with the surroundings; draws using the palette foreground color (without any 3D effect). flat, unbothered, moisturized.QFrame::Raisedβ the frame and contents appear raised; draws a 3D raised line using the light and dark colors of the current color group. main character energy β¬οΈQFrame::Sunkenβ the frame and contents appear sunken; draws a 3D sunken line using the light and dark colors of the current color group. she's going THROUGH it β¬οΈQFrame::MShadowβ internal; mask for the shadow. don't touch, that's staff only π
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.
QFrame::Shape
this enum type defines the shapes of a QFrame's frame. pick your fighter π₯
QFrame::NoFrameβQFramedraws nothing. the invisible queen. we love a minimal moment.QFrame::BoxβQFramedraws a box around its contentsQFrame::PanelβQFramedraws a panel to make the contents appear raised or sunkenQFrame::StyledPanelβ draws a rectangular panel with a look that depends on the current GUI style. it can be raised or sunken.QFrame::HLineβQFramedraws a horizontal line that frames nothing (useful as separator). framing nothing and serving anyway. iconic.QFrame::VLineβQFramedraws a vertical line that frames nothing (useful as separator)QFrame::GroupBoxPanelβ draws a rectangular panelQFrame::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. β οΈWinPanelis provided for compatibility. for GUI style independence we recommend usingStyledPanelinstead. (it's giving legacy, bestie, but she's still cute.)QFrame::ToolBarPanelQFrame::MenuBarPanelQFrame::PopupPanelQFrame::LineEditPanelβ is used to draw a frame suitable for line edits. the look depends upon the current GUI style.QFrame::TabWidgetPanelβ is used to draw a frame suitable for tab widgets. the look depends upon the current GUI style.QFrame::MShapeβ internal mask. again: staff only π
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().
π MEMBER FUNCTION DOCUMENTATION π
QFrame::QFrame ( QWidget * parent = 0, const char * name = 0, WFlags f = 0 )
constructs a frame widget with frame style NoFrame and a 1-pixel frame width. baby's first frame. π
the parent, name and f arguments are passed to the QWidget constructor.
QRect QFrame::contentsRect () const
returns the rectangle inside the frame. see the "contentsRect" property for details. β¨
void QFrame::drawContents ( QPainter * ) [virtual protected]
virtual function that draws the contents of the frame. this is where the subclass gets to be creative. π¨
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. no cap, that one will bite you.
this function is reimplemented by subclasses that draw something inside the frame. it should only draw inside contentsRect(). the default function does nothing. (relatable honestly π)
See also contentsRect and QPainter::setClipRect().
Reimplemented in QLabel, QLCDNumber, QMenuBar, and QPopupMenu.
void QFrame::drawFrame ( QPainter * p ) [virtual protected]
draws the frame using the painter p and 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(), and palette.
void QFrame::frameChanged () [virtual protected]
virtual function that is called when the frame style, line width or mid-line width changes. it's the "hey bestie, something changed" notification. π
this function can be reimplemented by subclasses that need to know when the frame attributes change.
the default implementation calls update().
QRect QFrame::frameRect () const
returns the frame rectangle. see the "frameRect" property for details.
Shadow QFrame::frameShadow () const
returns the frame shadow value from the frame style. see the "frameShadow" property for details.
Shape QFrame::frameShape () const
returns the frame shape value from the frame style. see the "frameShape" property for details.
int QFrame::frameStyle () const
returns the frame style.
the default value is QFrame::NoFrame.
See also setFrameStyle(), frameShape, and frameShadow.
Example: scrollview/scrollview.cpp.
int QFrame::frameWidth () const
returns the width of the frame that is drawn. see the "frameWidth" property for details.
int QFrame::lineWidth () const
returns the line width. see the "lineWidth" property for details.
int QFrame::margin () const
returns the width of the margin. see the "margin" property for details.
int QFrame::midLineWidth () const
returns the width of the mid-line. see the "midLineWidth" property for details.
void QFrame::paintEvent ( QPaintEvent * event ) [virtual protected]
processes the paint event event.
paints the frame and the contents. π¨
opens the painter on the frame and calls drawFrame(), then drawContents(). in that order. don't flip it.
Examples:
Reimplemented from QWidget.
void QFrame::resizeEvent ( QResizeEvent * e ) [virtual protected]
processes the resize event e.
adjusts the frame rectangle for the resized widget. the frame rectangle is elastic, and the surrounding area is static.
β οΈ the resulting frame rectangle may be null or invalid. you can use setMinimumSize() to avoid those possibilities. like, actually do that. π
nothing is done if the frame rectangle is a null rectangle already.
Example: life/life.cpp.
Reimplemented from QWidget.
void QFrame::setFrameRect ( const QRect & ) [virtual]
sets the frame rectangle. see the "frameRect" property for details.
void QFrame::setFrameShadow ( Shadow )
sets the frame shadow value from the frame style. see the "frameShadow" property for details.
void QFrame::setFrameShape ( Shape )
sets the frame shape value from the frame style. see the "frameShape" property for details.
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. so like, QFrame::Panel | QFrame::Raised. you know the vibe. π
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, frameStyle(), colorGroup, and QColorGroup.
Examples:
void QFrame::setLineWidth ( int ) [virtual]
sets the line width. see the "lineWidth" property for details.
void QFrame::setMargin ( int ) [virtual]
sets the width of the margin. see the "margin" property for details.
okay that's the whole first half, and there's still more of her to go β don't go anywhere bestie, part 2 is coming π
void QFrame::setMidLineWidth ( int )[virtual] β bestie this one sets the width of the mid-line, that's it, that's the whole job π peek at the"midLineWidth"property for the deets, she explains herself better than I ever could π«Ά
π PROPERTY DOCUMENTATION π
okay so this is the part where every single property gets its own lil moment in the spotlight β¨ and yes, they all ate, no skips, no filler π
πΈ QRect contentsRect πΈ
this property holds the rectangle inside the frame. like, the cozy lil space where your actual content lives π
get this property's value with contentsRect().
see also frameRect and drawContents() β they're the squad, they roll together π«
π¦ QRect frameRect π¦
this property holds the frame rectangle. that's the rectangle the frame gets drawn in, periodt π
by default, this is the entire widget β she takes up the whole room, main character energy fr fr π
setting this property does not cause a widget update. like, it changes nothing visually until something else pokes it, no cap π
if this property is set to a null rectangle (for example QRect(0, 0, 0, 0)), then the frame rectangle is equivalent to the widget rectangle. so like... a null rect lowkey means "just do the whole widget, bestie" π
see also contentsRect.
set this property's value with setFrameRect() and get this property's value with frameRect(). β¨
π Shadow frameShadow π
this property holds the frame shadow value from the frame style. it's giving drama, it's giving depth π
set this property's value with setFrameShadow() and get this property's value with frameShadow().
see also frameStyle() and frameShape.
π§ Shape frameShape π§
this property holds the frame shape value from the frame style. the silhouette, the lewk, the ~shape~ of it all β¨
set this property's value with setFrameShape() and get this property's value with frameShape().
see also frameStyle() and frameShadow.
π₯ int frameWidth π₯
this property holds the width of the frame that is drawn.
okay so important bestie, listen up: the frame width depends on the frame style, not only the line width and the mid-line width. they are not the same thing and conflating them is how you get confused π
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. and the frame width also includes the margin, so she's a package deal π
see also lineWidth, midLineWidth, frameStyle(), and margin.
get this property's value with frameWidth(). β
π int lineWidth π
this property holds the line width.
heads up bestie: the total line width forHLineandVLineis given byframeWidth(), notlineWidth(). sneaky lil gotcha, iykyk π
the default value is 1.
see also midLineWidth and frameWidth.
set this property's value with setLineWidth() and get this property's value with lineWidth(). π
π int margin π
this property holds 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(). so it's inside the frame's total width budget, not extra π
the margin is filled according to backgroundMode().
the default value is 0.
see also margin, lineWidth, and frameWidth.
set this property's value with setMargin() and get this property's value with margin(). π«Ά
π int midLineWidth π
this property holds the width of the mid-line.
the default value is 0.
see also lineWidth and frameWidth.
set this property's value with setMidLineWidth() and get this property's value with midLineWidth(). β¨
π SEE ALSO π
π COPYRIGHT π
Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com. See the license file included in the distribution for a complete license statement.
βοΈ AUTHOR βοΈ
Generated automatically from the source code.
not a human bestie, a machine did this. she doesn't miss, she doesn't sleep, she just generates π
π BUGS π
if you find a bug in Qt, please report it as described in http://doc.trolltech.com/bughowto.html. good bug reports help us to help you. thank you. π«Ά
the definitive Qt documentation is provided in HTML format; it is located at $QTDIR/doc/html and can be read using Qt Assistant or with a web browser. this man page is provided as a convenience for those users who prefer man pages, although this format is not officially supported by Trolltech. (translation: she's a lil unofficial treat, be nice to her π₯Ί)
if you find errors in 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 (3.3.8). otherwise they're out here searching for a ghost π»
and that's a wrap on QFrame(3qt) bestie π this lil document came to you from Trolltech AS, dated 2 February 2007 β iconic, timeless, a true era β¨ go forth and draw some frames, you absolute legend π
π¦ where this page comes from
- fedora 43: qt3-devel-docs 3.3.8b-102.fc43 Β· QPL-1.0 OR GPL-2.0-only OR GPL-3.0-only
- fedora 44: qt3-devel-docs 3.3.8b-103.fc44 Β· QPL-1.0 OR GPL-2.0-only OR GPL-3.0-only
- Copyright 1992-2007 Trolltech ASA. All rights reserved. See the
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms