Eneboo - Documentación para desarrolladores
|
The QFrame class is the base class of widgets that can have a frame. Más...
#include <qframe.h>
Tipos públicos | |
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, 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, Plain = 0x0010, Raised = 0x0020, Sunken = 0x0030, MShadow = 0x00f0 } |
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, 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, Plain = 0x0010, Raised = 0x0020, Sunken = 0x0030, MShadow = 0x00f0 } |
Métodos públicos | |
QFrame (QWidget *parent=0, const char *name=0, WFlags f=0) | |
int | frameStyle () const |
virtual void | setFrameStyle (int) |
int | frameWidth () const |
QRect | contentsRect () const |
bool | lineShapesOk () const |
QSize | sizeHint () const |
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 &) |
QFrame (QWidget *parent=0, const char *name=0, WFlags f=0) | |
int | frameStyle () const |
virtual void | setFrameStyle (int) |
int | frameWidth () const |
QRect | contentsRect () const |
bool | lineShapesOk () const |
QSize | sizeHint () const |
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 &) |
Métodos protegidos | |
void | paintEvent (QPaintEvent *) |
void | resizeEvent (QResizeEvent *) |
virtual void | drawFrame (QPainter *) |
virtual void | drawContents (QPainter *) |
virtual void | frameChanged () |
void | styleChange (QStyle &) |
void | paintEvent (QPaintEvent *) |
void | resizeEvent (QResizeEvent *) |
virtual void | drawFrame (QPainter *) |
virtual void | drawContents (QPainter *) |
virtual void | frameChanged () |
void | styleChange (QStyle &) |
Propiedades | |
int | frameWidth |
the width of the frame that is drawn. | |
QRect | contentsRect |
the rectangle inside the frame | |
Shape | frameShape |
the frame shape value from the frame style | |
Shadow | frameShadow |
the frame shadow value from the frame style | |
int | lineWidth |
the line width | |
int | margin |
the width of the margin | |
int | midLineWidth |
the width of the mid-line | |
QRect | frameRect |
the frame rectangle |
The QFrame class is the base class of widgets that can have a frame.
It draws a frame and calls a virtual function, drawContents(), to fill in the frame. This function is reimplemented by subclasses. There are also two other less useful functions: drawFrame() and frameChanged().
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
, 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.
The margin is the gap between the frame and the contents of the frame.
picture This table shows the most useful combinations of styles and widths (and some rather useless ones):
frames.png Table of frame styles
enum QFrame::Shadow |
This enum type defines the 3D effect used for QFrame's frame.
Plain the frame and contents appear level with the surroundings; draws using the palette foreground color (without any 3D effect) Raised the frame and contents appear raised; draws a 3D raised line using the light and dark colors of the current color group Sunken the frame and contents appear sunken; draws a 3D sunken line using the light and dark colors of the current color group MShadow internal; mask for the shadow
Shadow interacts with QFrame::Shape, the lineWidth() and the midLineWidth(). See the picture of the frames in the class description.
enum QFrame::Shadow |
enum QFrame::Shape |
enum QFrame::Shape |
This enum type defines the shapes of a QFrame's frame.
NoFrame QFrame draws nothing Box QFrame draws a box around its contents Panel QFrame draws a panel to make the contents appear raised or sunken StyledPanel draws a rectangular panel with a look that depends on the current GUI style. It can be raised or sunken. HLine QFrame draws a horizontal line that frames nothing (useful as separator) VLine QFrame draws a vertical line that frames nothing (useful as separator) GroupBoxPanel draws a rectangular panel 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. ToolBarPanel MenuBarPanel PopupPanel LineEditPanel is used to draw a frame suitable for line edits. The look depends upon the current GUI style. TabWidgetPanel is used to draw a frame suitable for tab widgets. The look depends upon the current GUI style. MShape internal mask
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.
Constructs a frame widget with frame style NoFrame
and a 1-pixel frame width.
The parent, name and f arguments are passed to the QWidget constructor.
QRect QFrame::contentsRect | ( | ) | const |
QRect QFrame::contentsRect | ( | ) | const |
void QFrame::drawContents | ( | QPainter * | ) | [protected, virtual] |
Virtual function that draws the contents of the frame.
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.
This function is reimplemented by subclasses that draw something inside the frame. It should only draw inside contentsRect(). The default function does nothing.
Reimplementado en QDockWindow, QLabel, QLCDNumber, QLineEdit, QMenuBar, QPopupMenu, QProgressBar, QColorPicker, QColorShowLabel, QDockWindow, QLabel, QLCDNumber, QLineEdit, QMenuBar, QPopupMenu, QProgressBar, QwtPlotCanvas y QwtTextLabel.
virtual void QFrame::drawContents | ( | QPainter * | ) | [protected, virtual] |
Reimplementado en QDockWindow, QLabel, QLCDNumber, QLineEdit, QMenuBar, QPopupMenu, QProgressBar, QColorPicker, QColorShowLabel, QDockWindow, QLabel, QLCDNumber, QLineEdit, QMenuBar, QPopupMenu, QProgressBar, QwtPlotCanvas y QwtTextLabel.
void QFrame::drawFrame | ( | QPainter * | p | ) | [protected, virtual] |
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.
Reimplementado en QDockWindow, QDockWindow y QWorkspaceChild.
virtual void QFrame::drawFrame | ( | QPainter * | ) | [protected, virtual] |
Reimplementado en QDockWindow, QDockWindow y QWorkspaceChild.
void QFrame::frameChanged | ( | ) | [protected, virtual] |
Virtual function that is called when the frame style, line width or mid-line width changes.
This function can be reimplemented by subclasses that need to know when the frame attributes change.
The default implementation calls update().
Reimplementado en QGrid, QHBox, QScrollView, QToolBox, QWidgetStack, QGrid, QHBox, QScrollView, QToolBox y QWidgetStack.
virtual void QFrame::frameChanged | ( | ) | [protected, virtual] |
Reimplementado en QGrid, QHBox, QScrollView, QToolBox, QWidgetStack, QGrid, QHBox, QScrollView, QToolBox y QWidgetStack.
QRect QFrame::frameRect | ( | ) | const |
QRect QFrame::frameRect | ( | ) | const |
Shadow QFrame::frameShadow | ( | ) | const |
Shadow QFrame::frameShadow | ( | ) | const |
Shape QFrame::frameShape | ( | ) | const |
Shape QFrame::frameShape | ( | ) | const |
int QFrame::frameStyle | ( | ) | const [inline] |
Returns the frame style.
The default value is QFrame::NoFrame.
int QFrame::frameStyle | ( | ) | const |
int QFrame::frameWidth | ( | ) | const |
int QFrame::frameWidth | ( | ) | const |
bool QFrame::lineShapesOk | ( | ) | const [inline] |
bool QFrame::lineShapesOk | ( | ) | const [inline] |
int QFrame::lineWidth | ( | ) | const |
int QFrame::lineWidth | ( | ) | const |
int QFrame::margin | ( | ) | const |
Reimplementado en QwtPlot y QwtTextLabel.
int QFrame::margin | ( | ) | const |
Reimplementado en QwtPlot y QwtTextLabel.
int QFrame::midLineWidth | ( | ) | const |
int QFrame::midLineWidth | ( | ) | const |
void QFrame::paintEvent | ( | QPaintEvent * | event | ) | [protected, virtual] |
Processes the paint event event.
Paints the frame and the contents.
Opens the painter on the frame and calls drawFrame(), then drawContents().
Reimplementado de QWidget.
Reimplementado en QGroupBox, QPopupMenu, QTable, QtTableView, QTable, QGroupBox, QPopupMenu, QDesignerToolBar, MenuBarEditor, QwtLegendItem, QwtPlotCanvas y QwtTextLabel.
void QFrame::paintEvent | ( | QPaintEvent * | ) | [protected, virtual] |
This event handler can be reimplemented in a subclass to receive paint events.
A paint event is a request to repaint all or part of the widget. It can happen as a result of repaint() or update(), or because the widget was obscured and has now been uncovered, or for many other reasons.
Many widgets can simply repaint their entire surface when asked to, but some slow widgets need to optimize by painting only the requested region: QPaintEvent::region(). This speed optimization does not change the result, as painting is clipped to that region during event processing. QListView and QCanvas do this, for example.
Qt also tries to speed up painting by merging multiple paint events into one. When update() is called several times or the window system sends several paint events, Qt merges these events into one event with a larger region (see QRegion::unite()). repaint() does not permit this optimization, so we suggest using update() when possible.
When the paint event occurs, the update region has normally been erased, so that you're painting on the widget's background. There are a couple of exceptions and QPaintEvent::erased() tells you whether the widget has been erased or not.
The background can be set using setBackgroundMode(), setPaletteBackgroundColor() or setBackgroundPixmap(). The documentation for setBackgroundMode() elaborates on the background; we recommend reading it.
Reimplementado de QWidget.
Reimplementado en QGroupBox, QPopupMenu, QTable, QtTableView, QTable, QGroupBox, QPopupMenu, QDesignerToolBar, MenuBarEditor, QwtLegendItem, QwtPlotCanvas y QwtTextLabel.
void QFrame::resizeEvent | ( | QResizeEvent * | e | ) | [protected, virtual] |
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.
Nothing is done if the frame rectangle is a null rectangle already.
Reimplementado de QWidget.
Reimplementado en VDatePopup, VPopupFrame, QDataTable, QDockWindow, QGroupBox, QIconView, QLabel, QLineEdit, QListBox, QListView, QMenuBar, QScrollView, QSplitter, QTextEdit, QToolBar, QWidgetStack, QtMultiLineEdit, QtTableView, QIconView, QDataTable, QDockWindow, QGroupBox, QLabel, QLineEdit, QListBox, QListView, QMenuBar, QScrollView, QSplitter, QTextEdit, QToolBar, QWidgetStack, QWorkspaceChild, MenuBarEditor, PropertyList, QDesignerWidgetStack, EditorPage, QwtLegend y QwtPlot.
void QFrame::resizeEvent | ( | QResizeEvent * | ) | [protected, virtual] |
This event handler can be reimplemented in a subclass to receive widget resize events. When resizeEvent() is called, the widget already has its new geometry. The old size is accessible through QResizeEvent::oldSize().
The widget will be erased and receive a paint event immediately after processing the resize event. No drawing need be (or should be) done inside this handler.
Widgets that have been created with the WNoAutoErase
flag will not be erased. Nevertheless, they will receive a paint event for their entire area afterwards. Again, no drawing needs to be done inside this handler.
The default implementation calls updateMask() if the widget has automatic masking enabled.
Reimplementado de QWidget.
Reimplementado en VDatePopup, VPopupFrame, QDataTable, QDockWindow, QGroupBox, QIconView, QLabel, QLineEdit, QListBox, QListView, QMenuBar, QScrollView, QSplitter, QTextEdit, QToolBar, QWidgetStack, QtMultiLineEdit, QtTableView, QIconView, QDataTable, QDockWindow, QGroupBox, QLabel, QLineEdit, QListBox, QListView, QMenuBar, QScrollView, QSplitter, QTextEdit, QToolBar, QWidgetStack, QWorkspaceChild, MenuBarEditor, PropertyList, QDesignerWidgetStack, EditorPage, QwtLegend y QwtPlot.
void QFrame::setFrameRect | ( | const QRect & | r | ) | [virtual] |
Reimplementado en QWidgetStack y QWidgetStack.
virtual void QFrame::setFrameRect | ( | const QRect & | ) | [virtual] |
Reimplementado en QWidgetStack y QWidgetStack.
void QFrame::setFrameShadow | ( | Shadow | ) |
void QFrame::setFrameShadow | ( | QFrame::Shadow | s | ) | [inline] |
void QFrame::setFrameShape | ( | Shape | ) |
void QFrame::setFrameShape | ( | QFrame::Shape | s | ) | [inline] |
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.
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.
virtual void QFrame::setFrameStyle | ( | int | ) | [virtual] |
virtual void QFrame::setLineWidth | ( | int | ) | [virtual] |
void QFrame::setLineWidth | ( | int | w | ) | [virtual] |
void QFrame::setMargin | ( | int | w | ) | [virtual] |
Reimplementado en QwtPlot y QwtTextLabel.
virtual void QFrame::setMargin | ( | int | ) | [virtual] |
Reimplementado en QwtPlot y QwtTextLabel.
void QFrame::setMidLineWidth | ( | int | w | ) | [virtual] |
virtual void QFrame::setMidLineWidth | ( | int | ) | [virtual] |
QSize QFrame::sizeHint | ( | ) | const [virtual] |
Reimplementado de QWidget.
Reimplementado en VDatePopup, VDateInternalMonthPicker, VDateTable, QCanvasView, QDockWindow, QGrid, QGroupBox, QHBox, QIconView, QLabel, QLCDNumber, QLineEdit, QListBox, QListView, QMenuBar, QPopupMenu, QProgressBar, QScrollView, QSplitter, QTable, QTextEdit, QWidgetStack, QtMultiLineEdit, QCanvasView, QWellArray, QColorPicker, QColNumLineEdit, QErrorMessageTextView, QIconView, QTable, QDockWindow, QGrid, QGroupBox, QHBox, QLabel, QLCDNumber, QLineEdit, QListBox, QListView, QMenuBar, QPopupMenu, QProgressBar, QScrollView, QSplitter, QTextEdit, QWidgetStack, QWorkspaceChild, MenuBarEditor, PhraseLV, QwtLegend, QwtLegendItem, QwtPlot y QwtTextLabel.
QSize QFrame::sizeHint | ( | ) | const [virtual] |
Reimplementado de QWidget.
Reimplementado en VDatePopup, VDateInternalMonthPicker, VDateTable, QCanvasView, QDockWindow, QGrid, QGroupBox, QHBox, QIconView, QLabel, QLCDNumber, QLineEdit, QListBox, QListView, QMenuBar, QPopupMenu, QProgressBar, QScrollView, QSplitter, QTable, QTextEdit, QWidgetStack, QtMultiLineEdit, QCanvasView, QWellArray, QColorPicker, QColNumLineEdit, QErrorMessageTextView, QIconView, QTable, QDockWindow, QGrid, QGroupBox, QHBox, QLabel, QLCDNumber, QLineEdit, QListBox, QListView, QMenuBar, QPopupMenu, QProgressBar, QScrollView, QSplitter, QTextEdit, QWidgetStack, QWorkspaceChild, MenuBarEditor, PhraseLV, QwtLegend, QwtLegendItem, QwtPlot y QwtTextLabel.
void QFrame::styleChange | ( | QStyle & | ) | [protected, virtual] |
This virtual function is called when the style of the widgets changes. oldStyle is the previous GUI style; you can get the new style from style().
Reimplement this function if your widget needs to know when its GUI style changes. You will almost certainly need to update the widget using update().
The default implementation updates the widget including its geometry.
Reimplementado de QWidget.
Reimplementado en QIconView, QListView, QMenuBar, QPopupMenu, QProgressBar, QScrollView, QSplitter, QToolBar, QToolBox, QIconView, QListView, QMenuBar, QPopupMenu, QProgressBar, QScrollView, QSplitter, QToolBar, QToolBox y QWorkspaceChild.
void QFrame::styleChange | ( | QStyle & | old | ) | [protected, virtual] |
Reimplementado de QWidget.
Reimplementado en QIconView, QListView, QMenuBar, QPopupMenu, QProgressBar, QScrollView, QSplitter, QToolBar, QToolBox, QIconView, QListView, QMenuBar, QPopupMenu, QProgressBar, QScrollView, QSplitter, QToolBar, QToolBox y QWorkspaceChild.
QRect QFrame::contentsRect [read] |
the rectangle inside the frame
QRect QFrame::frameRect [read, write] |
the frame rectangle
The frame rectangle is the rectangle the frame is drawn in. By default, this is the entire widget. Setting this property does not cause a widget update.
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.
QFrame::Shadow QFrame::frameShadow [inline, read, write] |
the frame shadow value from the frame style
QFrame::Shape QFrame::frameShape [inline, read, write] |
the frame shape value from the frame style
int QFrame::frameWidth [inline, read] |
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. The frame width also includes the margin.
int QFrame::lineWidth [inline, read, write] |
the line width
Note that the total line width for HLine
and VLine
is given by frameWidth(), not lineWidth().
The default value is 1.
int QFrame::margin [inline, read, write] |
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().
The margin is filled according to backgroundMode().
The default value is 0.
Reimplementado en QwtTextLabel.
int QFrame::midLineWidth [inline, read, write] |