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  ·  Toutes les fonctions  ·  Vues d'ensemble  · 

QFrame Class Reference
[QtGui module]

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

 #include <QFrame>

Inherits QWidget.

Inherited by Q3Frame, Q3ProgressBar, QAbstractScrollArea, QLabel, QLCDNumber, QSplitter, QStackedWidget, and QToolBox.


Public Types

enum Shadow { Plain, Raised, Sunken }
enum Shape { NoFrame, Box, Panel, StyledPanel, ..., WinPanel }
enum StyleMask { Shadow_Mask, Shape_Mask }

Properties

  • 58 properties inherited from QWidget
  • 1 property inherited from QObject

Public Functions

QFrame ( QWidget * parent = 0, Qt::WindowFlags f = 0 )
~QFrame ()
QRect frameRect () const
Shadow frameShadow () const
Shape frameShape () const
int frameStyle () const
int frameWidth () const
int lineWidth () const
int midLineWidth () const
void setFrameRect ( const QRect & )
void setFrameShadow ( Shadow )
void setFrameShape ( Shape )
void setFrameStyle ( int style )
void setLineWidth ( int )
void setMidLineWidth ( int )

Reimplemented Public Functions

virtual QSize sizeHint () const
  • 217 public functions inherited from QWidget
  • 29 public functions inherited from QObject
  • 13 public functions inherited from QPaintDevice

Reimplemented Protected Functions

virtual void changeEvent ( QEvent * ev )
virtual bool event ( QEvent * e )
virtual void paintEvent ( QPaintEvent * )
  • 37 protected functions inherited from QWidget
  • 7 protected functions inherited from QObject
  • 1 protected function inherited from QPaintDevice

Additional Inherited Members

  • 19 public slots inherited from QWidget
  • 1 public slot inherited from QObject
  • 1 signal inherited from QWidget
  • 1 signal inherited from QObject
  • 4 static public members inherited from QWidget
  • 5 static public members inherited from QObject
  • 37 protected functions inherited from QWidget
  • 7 protected functions inherited from QObject
  • 1 protected function inherited from QPaintDevice
  • 1 protected slot inherited from QWidget

Detailed Description

The QFrame 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);

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

The frame style is specified by a frame shape and a shadow style that is used to visually separate the frame from surrounding widgets. These properties can be set together using the setFrameStyle() function and read with frameStyle().

The frame shapes are NoFrame, Box, Panel, StyledPanel, HLine and VLine; the shadow styles are Plain, Raised and Sunken.

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

  • 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 for Box, HLine and VLine frames that are raised or sunken.
  • The frame width is determined by the frame style, and the frameWidth() 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 the QWidget::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 palette QPalette::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 with QFrame::Shape, the lineWidth() and the midLineWidth(). See the picture of the frames in the main class documentation.

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

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 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 main class documentation.

See also QFrame::Shadow, QFrame::style(), and QStyle::drawPrimitive().

enum QFrame::StyleMask

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

ConstantValueDescription
QFrame::Shadow_Mask0x00f0The Shadow part of frameStyle()
QFrame::Shape_Mask0x000fThe Shape part of frameStyle()

Normally, you don't need to use these, since frameShadow() and frameShape() already extract the Shadow and the Shape parts of frameStyle().

See also frameStyle() and setFrameStyle().


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 does not 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 the widget rectangle.

Access functions:

QRect frameRect () const
void setFrameRect ( const QRect & )

frameShadow : Shadow

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

Access functions:

Shadow frameShadow () const
void setFrameShadow ( Shadow )

See also frameStyle() and frameShape().

frameShape : Shape

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

Access functions:

Shape frameShape () const
void setFrameShape ( Shape )

See also frameStyle() and frameShadow().

frameWidth : const int

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 specified by NoFrame always has a frame width of 0, whereas the style Panel has a frame width equivalent to the line width.

Access functions:

int frameWidth () const

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

lineWidth : int

This property holds the line width.

Note that the total line width for frames used as separators (HLine and VLine) is specified by frameWidth.

The default value is 1.

Access functions:

int lineWidth () const
void setLineWidth ( int )

See also midLineWidth and frameWidth.

midLineWidth : int

This property holds the width of the mid-line.

The default value is 0.

Access functions:

int midLineWidth () const
void setMidLineWidth ( int )

See also lineWidth and frameWidth.


Member Function Documentation

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

Constructs a frame widget with frame style NoFrame and a 1-pixel frame width.

The parent and f arguments are passed to the QWidget constructor.

QFrame::~QFrame ()

Destroys the frame.

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

Reimplemented from QWidget::changeEvent().

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

Reimplemented from QObject::event().

int QFrame::frameStyle () const

Returns the frame style.

The default value is QFrame::NoFrame.

See also setFrameStyle(), frameShape(), and frameShadow().

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

Reimplemented from QWidget::paintEvent().

void QFrame::setFrameStyle ( int style )

Sets the frame style to style.

The style 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 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 frameStyle().

QSize QFrame::sizeHint () const   [virtual]

Reimplemented from QWidget::sizeHint().

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 94
  2. Apercevoir la troisième dimension ou l'utilisation multithreadée d'OpenGL dans Qt, un article des Qt Quarterly traduit par Guillaume Belz 0
  3. Pourquoi les programmeurs sont-ils moins payés que les gestionnaires de programmes ? Manquent-ils de pouvoir de négociation ? 43
  4. Les développeurs ignorent-ils trop les failles découvertes dans leur code ? Prenez-vous en compte les remarques des autres ? 17
  5. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
  6. Qt Commercial : Digia organise un webinar gratuit le 27 mars sur la conception d'interfaces utilisateur et d'applications avec le framework 0
  7. 2017 : un quinquennat pour une nouvelle version du C++ ? Possible, selon Herb Sutter 9
Page suivante

Le Qt Quarterly au hasard

Logo

Des apparences personnalisées utilisant les feuilles de style

Qt Quarterly est la revue trimestrielle proposée par Nokia et à destination des développeurs Qt. Ces articles d'une grande qualité technique sont rédigés par des experts Qt. 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 4.6-snapshot
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