Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Toutes les classes  ·  Classes principales  ·  Annotées  ·  Classes groupées  ·  Fonctions  · 

QFrame Class Reference

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

#include <qframe.h>

Inherits QWidget.

Inherited by QGroupBox, QScrollView, QDockWindow, QGrid, QHBox, QLabel, QLCDNumber, QLineEdit, QMenuBar, QPopupMenu, QProgressBar, QSplitter, QToolBox, and QWidgetStack.

List of all member functions.

Public Members

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


Detailed Description

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.

This table shows the most useful combinations of styles and widths (and some rather useless ones):

Table of frame styles

See also Abstract Widget Classes.


Member Type Documentation

QFrame::Shadow

This enum type defines the 3D effect used for QFrame's frame.

  • QFrame::Plain - the frame and contents appear level with the surroundings; draws using the palette foreground 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
  • QFrame::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.

See also QFrame::Shape, lineWidth, and midLineWidth.

QFrame::Shape

This enum type defines the shapes of a QFrame's frame.

  • QFrame::NoFrame - QFrame draws nothing
  • 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)
  • 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.
  • 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

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.

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.

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.

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.

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().

Examples: life/life.cpp and qfd/fontdisplayer.cpp.

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.

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.

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: cursor/cursor.cpp, layout/layout.cpp, listboxcombo/listboxcombo.cpp, rangecontrols/rangecontrols.cpp, scrollview/scrollview.cpp, tabdialog/tabdialog.cpp, and tictac/tictac.cpp.

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.

void QFrame::setMidLineWidth ( int ) [virtual]

Sets the width of the mid-line. See the "midLineWidth" property for details.


Property Documentation

QRect contentsRect

This property holds the rectangle inside the frame.

Get this property's value with contentsRect().

See also frameRect and drawContents().

QRect frameRect

This property holds 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.

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.

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.

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.

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.

See also lineWidth, midLineWidth, frameStyle(), and margin.

Get this property's value with frameWidth().

int lineWidth

This property holds the line width.

Note that the total line width for HLine and VLine is given by frameWidth(), not lineWidth().

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().

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().


This file is part of the Qt toolkit. Copyright © 1995-2005 Trolltech. All Rights Reserved.

Publicité

Best Of

Actualités les plus lues

Semaine
Mois
Année
  1. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 56
  2. Les développeurs ignorent-ils trop les failles découvertes dans leur code ? Prenez-vous en compte les remarques des autres ? 17
  3. Apercevoir la troisième dimension ou l'utilisation multithreadée d'OpenGL dans Qt, un article des Qt Quarterly traduit par Guillaume Belz 0
  4. BlackBerry 10 : premières images du prochain OS de RIM qui devrait intégrer des widgets et des tuiles inspirées de Windows Phone 0
  5. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
  6. Adieu qmake, bienvenue qbs : Qt Building Suite, un outil déclaratif et extensible pour la compilation de projets Qt 17
  7. La rubrique Qt a besoin de vous ! 1
Page suivante

Le Qt Developer Network au hasard

Logo

Combiner licence, à propos et fermer d'une dernière manière

Le Qt Developer Network est un réseau de développeurs Qt anglophone, où ils peuvent partager leur expérience sur le framework. Lire l'article.

Communauté

Ressources

Liens utiles

Contact

  • Vous souhaitez rejoindre la rédaction ou proposer un tutoriel, une traduction, une question... ? Postez dans le forum Contribuez ou contactez-nous par MP ou par email (voir en bas de page).

Qt dans le magazine

Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. Qt 3.3
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP !
 
 
 
 
Partenaires

Hébergement Web