QFrame(3qt)

πŸ“¦ version 3.3.8b, in fedora 43, fedora 44

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 () const
  • virtual void setFrameStyle ( int style )
  • int frameWidth () const
  • QRect contentsRect () const
  • enum 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 () 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 & )

πŸ¦‹ Properties πŸ¦‹

  • QRect contentsRect β€” the rectangle inside the frame (read only) πŸ”’
  • QRect frameRect β€” the frame rectangle
  • Shadow frameShadow β€” the frame shadow value from the frame style
  • Shape frameShape β€” the frame shape value from the frame style
  • int frameWidth β€” the width of the frame that is drawn (read only) πŸ”’
  • int lineWidth β€” the line width
  • int margin β€” the width of the margin
  • int midLineWidth β€” 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 β€” QFrame draws nothing. the invisible queen. we love a minimal moment.
  • 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). framing nothing and serving anyway. iconic.
  • QFrame::VLine β€” QFrame draws a vertical line that frames nothing (useful as separator)
  • QFrame::GroupBoxPanel β€” draws a rectangular panel
  • 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. (it's giving legacy, bestie, but she's still cute.)
  • QFrame::ToolBarPanel
  • QFrame::MenuBarPanel
  • QFrame::PopupPanel
  • QFrame::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 for HLine and VLine is given by frameWidth(), not lineWidth(). 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 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