QSplitterHandle Class ReferenceThe QSplitterHandle class provides handle functionality of the splitter. More... #include <QSplitterHandle> Inherits: QWidget. Public Functions
Reimplemented Public Functions
Protected Functions
Reimplemented Protected Functions
Additional Inherited Members
Detailed DescriptionThe QSplitterHandle class provides handle functionality of the splitter. QSplitterHandle is typically what people think about when they think about a splitter. It is the handle that is used to resize the widgets. A typical developer using QSplitter will never have to worry about QSplitterHandle. It is provided for developers who want splitter handles that provide extra features, such as popup menus. The typical way one would create splitter handles is to subclass QSplitter then reimplement QSplitter::createHandle() to instantiate the custom splitter handle. For example, a minimum QSplitter subclass might look like this: class Splitter : public QSplitter { public: Splitter(Qt::Orientation orientation, QWidget *parent = 0); protected: QSplitterHandle *createHandle(); }; The createHandle() implementation simply constructs a custom splitter handle, called Splitter in this example: QSplitterHandle *Splitter::createHandle() { return new SplitterHandle(orientation(), this); } Information about a given handle can be obtained using functions like orientation() and opaqueResize(), and is retrieved from its parent splitter. Details like these can be used to give custom handles different appearances depending on the splitter's orientation. The complexity of a custom handle subclass depends on the tasks that it needs to perform. A simple subclass might only provide a paintEvent() implementation: void SplitterHandle::paintEvent(QPaintEvent *event) { QPainter painter(this); if (orientation() == Qt::Horizontal) { gradient.setStart(rect().left(), rect().height()/2); gradient.setFinalStop(rect().right(), rect().height()/2); } else { gradient.setStart(rect().width()/2, rect().top()); gradient.setFinalStop(rect().width()/2, rect().bottom()); } painter.fillRect(event->rect(), QBrush(gradient)); } In this example, a predefined gradient is set up differently depending on the orientation of the handle. QSplitterHandle provides a reasonable size hint for the handle, so the subclass does not need to provide a reimplementation of sizeHint() unless the handle has special size requirements. See also QSplitter. Member Function Documentation
|
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.8 | |
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 ! |
Copyright © 2000-2012 - www.developpez.com