Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
splitter.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3
4#include <QtGui>
5
6#include "splitter.h"
7
8SplitterHandle::SplitterHandle(Qt::Orientation orientation, QSplitter *parent)
10{
11 gradient.setColorAt(0.0, Qt::darkGreen);
12 gradient.setColorAt(0.25, Qt::white);
13 gradient.setColorAt(1.0, Qt::darkGreen);
14}
15
16//! [0]
17void SplitterHandle::paintEvent(QPaintEvent *event)
18{
19 QPainter painter(this);
20 if (orientation() == Qt::Horizontal) {
21 gradient.setStart(rect().left(), rect().height()/2);
22 gradient.setFinalStop(rect().right(), rect().height()/2);
23 } else {
24 gradient.setStart(rect().width()/2, rect().top());
25 gradient.setFinalStop(rect().width()/2, rect().bottom());
26 }
27 painter.fillRect(event->rect(), QBrush(gradient));
28}
29//! [0]
30
31Splitter::Splitter(Qt::Orientation orientation, QWidget *parent)
33{
34}
35
36//! [1]
38{
39 return new SplitterHandle(orientation(), this);
40}
41//! [1]
SplitterHandle(Qt::Orientation orientation, QSplitter *parent)
Definition splitter.cpp:8
void paintEvent(QPaintEvent *event) override
[0]
Definition splitter.cpp:17
[0]
Definition splitter.h:15
Splitter(Qt::Orientation orientation, QWidget *parent=nullptr)
[0]
Definition splitter.cpp:31
QSplitterHandle * createHandle() override
[1]
Definition splitter.cpp:37