The QSplitterHandle class provides handle functionality of the splitter. More...
#include <QSplitterHandle>
Inherits: QWidget.
QSplitterHandle ( Qt::Orientation orientation, QSplitter * parent ) | |
bool | opaqueResize () const |
Qt::Orientation | orientation () const |
void | setOrientation ( Qt::Orientation orientation ) |
QSplitter * | splitter () const |
virtual QSize | sizeHint () const |
int | closestLegalPosition ( int pos ) |
void | moveSplitter ( int pos ) |
virtual bool | event ( QEvent * event ) |
virtual void | mouseMoveEvent ( QMouseEvent * e ) |
virtual void | mousePressEvent ( QMouseEvent * e ) |
virtual void | mouseReleaseEvent ( QMouseEvent * e ) |
virtual void | paintEvent ( QPaintEvent * ) |
virtual void | resizeEvent ( QResizeEvent * event ) |
The 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.
Creates a QSplitter handle with the given orientation and QSplitter parent.
Returns the closest legal position to pos of the splitter handle. The positions are measured from the left or top edge of the splitter, even for right-to-left languages.
See also QSplitter::closestLegalPosition() and moveSplitter().
Reimplemented from QObject::event().
Reimplemented from QWidget::mouseMoveEvent().
Reimplemented from QWidget::mousePressEvent().
Reimplemented from QWidget::mouseReleaseEvent().
Tells the splitter to move this handle to position pos, which is the distance from the left or top edge of the widget.
Note that pos is also measured from the left (or top) for right-to-left languages. This function will map pos to the appropriate position before calling QSplitter::moveSplitter().
See also QSplitter::moveSplitter() and closestLegalPosition().
Returns true if widgets are resized dynamically (opaquely), otherwise returns false. This value is controlled by the QSplitter.
See also QSplitter::opaqueResize().
Returns the handle's orientation. This is usually propagated from the QSplitter.
See also setOrientation() and QSplitter::orientation().
Reimplemented from QWidget::paintEvent().
Reimplemented from QWidget::resizeEvent().
Sets the orientation of the splitter handle to orientation. This is usually propagated from the QSplitter.
See also orientation() and QSplitter::setOrientation().
Reimplemented from QWidget::sizeHint().
Returns the splitter associated with this splitter handle.
See also QSplitter::handle().
© 2008-2011 Nokia Corporation and/or its subsidiaries. Nokia, Qt and their respective logos are trademarks of Nokia Corporation in Finland and/or other countries worldwide.
All other trademarks are property of their respective owners. Privacy Policy
Licensees holding valid Qt Commercial licenses may use this document in accordance with the Qt Commercial License Agreement provided with the Software or, alternatively, in accordance with the terms contained in a written agreement between you and Nokia.
Alternatively, this document may be used under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation.