QSplitterHandle Class
The QSplitterHandle class provides handle functionality for the splitter. 更多...
头文件: | #include <QSplitterHandle> |
qmake: | QT += widgets |
基类: | QWidget |
公有函数
QSplitterHandle(Qt::Orientation orientation, QSplitter *parent) | |
~QSplitterHandle() | |
bool | opaqueResize() const |
Qt::Orientation | orientation() const |
void | setOrientation(Qt::Orientation orientation) |
QSplitter * | splitter() const |
重新实现的公有函数
virtual QSize | sizeHint() const |
- 214 个公有函数继承自 QWidget
- 32 个公有函数继承自 QObject
- 14 个公有函数继承自 QPaintDevice
受保护的函数
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) |
- 35 个受保护的函数继承自 QWidget
- 9 个受保护的函数继承自 QObject
- 1 个受保护的函数继承自 QPaintDevice
其他继承的成员
- 59 个属性继承自 QWidget
- 1 个属性继承自 QObject
- 19 个公有槽函数继承自 QWidget
- 1 个公有槽函数继承自 QObject
- 3 个信号继承自 QWidget
- 2 个信号继承自 QObject
- 1 个公有变量继承自 QObject
- 5 个静态公有成员继承自 QWidget
- 10 个静态公有成员继承自 QObject
- 1 个受保护的槽函数继承自 QWidget
- 2 个受保护的变量继承自 QObject
- 1 protected type inherited from QPaintDevice
详细描述
The QSplitterHandle class provides handle functionality for 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 and 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.
参见 QSplitter.
成员函数
QSplitterHandle::QSplitterHandle(Qt::Orientation orientation, QSplitter *parent)
Creates a QSplitter handle with the given orientation and parent.
QSplitterHandle::~QSplitterHandle()
Destructor.
[protected]
int QSplitterHandle::closestLegalPosition(int pos)
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.
参见 QSplitter::closestLegalPosition() and moveSplitter().
[virtual protected]
bool QSplitterHandle::event(QEvent *event)
重新实现 QObject::event().
[virtual protected]
void QSplitterHandle::mouseMoveEvent(QMouseEvent *e)
重新实现 QWidget::mouseMoveEvent().
[virtual protected]
void QSplitterHandle::mousePressEvent(QMouseEvent *e)
重新实现 QWidget::mousePressEvent().
[virtual protected]
void QSplitterHandle::mouseReleaseEvent(QMouseEvent *e)
重新实现 QWidget::mouseReleaseEvent().
[protected]
void QSplitterHandle::moveSplitter(int pos)
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().
参见 QSplitter::moveSplitter() and closestLegalPosition().
bool QSplitterHandle::opaqueResize() const
Returns true
if widgets are resized dynamically (opaquely), otherwise returns false
. This value is controlled by the QSplitter.
参见 QSplitter::opaqueResize().
Qt::Orientation QSplitterHandle::orientation() const
Returns the handle's orientation. This is usually propagated from the QSplitter.
参见 setOrientation() and QSplitter::orientation().
[virtual protected]
void QSplitterHandle::paintEvent(QPaintEvent *)
重新实现 QWidget::paintEvent().
[virtual protected]
void QSplitterHandle::resizeEvent(QResizeEvent *event)
重新实现 QWidget::resizeEvent().
void QSplitterHandle::setOrientation(Qt::Orientation orientation)
Sets the orientation of the splitter handle to orientation. This is usually propagated from the QSplitter.
参见 orientation() and QSplitter::setOrientation().
[virtual]
QSize QSplitterHandle::sizeHint() const
重新实现 QWidget::sizeHint().
QSplitter *QSplitterHandle::splitter() const
Returns the splitter associated with this splitter handle.
参见 QSplitter::handle().