-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscrollwidget.cpp
More file actions
67 lines (53 loc) · 1.84 KB
/
scrollwidget.cpp
File metadata and controls
67 lines (53 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include "scrollwidget.h"
#include <QDesktopWidget>
ScrollWidget::ScrollWidget(QWidget *parent) : QWidget(parent)
{
desktopWidget = new QDesktopWidget();
start = new QPoint(0, 10);
end = new QPoint(0, 50);
gradient = new QLinearGradient(*start, *end);
ticker = new Ticker(this);
screenRect = desktopWidget->availableGeometry();
setAutoFillBackground(true);
startPos = (( screenRect.width() * 5 ) / 100);
setGeometry(startPos, screenRect.height()-50, screenRect.width(), screenRect.height()/14);
qDebug()<<screenRect.width();
setMask(roundedRect(rect(), 20));
ticker->setText(" This document introduces Qt Assistant, a tool for presenting on-line documentation. The document is divided into the following sections: ");
ticker->show();
mainLayout = new QHBoxLayout(this);
mainLayout->addWidget(ticker);
}
QRegion ScrollWidget::roundedRect(const QRect& rect, int r)
{
QRegion region;
// middle and borders
region += rect.adjusted(r, 0, -r, 0);
region += rect.adjusted(0, r, 0, -r);
// top left
QRect corner(rect.topLeft(), QSize(r*2, r*2));
region += QRegion(corner, QRegion::Ellipse);
// top right
corner.moveTopRight(rect.topRight());
region += QRegion(corner, QRegion::Rectangle);
// bottom left
corner.moveBottomLeft(rect.bottomLeft());
region += QRegion(corner, QRegion::Rectangle);
// bottom right
corner.moveBottomRight(rect.bottomRight());
region += QRegion(corner, QRegion::Rectangle);
return region;
}
void ScrollWidget::paintEvent(QPaintEvent *)
{
/* Set the Gradient, To Look like 3D Toolbar */
QPainter painter(this);
gradient->setColorAt(0, Qt::lightGray);
gradient->setColorAt(1, Qt::darkGray);
painter.setBrush(*gradient);
painter.drawRect(rect());
}
ScrollWidget::~ScrollWidget()
{
//delete ticker;
}