-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMyOrganizationDockWidget.cpp
64 lines (37 loc) · 1.51 KB
/
MyOrganizationDockWidget.cpp
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
#include "MyOrganizationDockWidget.h"
MyOrganizationDockWidget::MyOrganizationDockWidget(
const QString & title, QWidget * parent, Qt::WindowFlags flags)
: QDockWidget(title, parent, flags){
this->setFixedWidth(200);
addShapes();
}
void MyOrganizationDockWidget::addShapes(){
scene = new QGraphicsScene();
QGraphicsView* view = new QGraphicsView(scene);
scene->setSceneRect(this->rect());
view->setSceneRect(this->rect());
QPointF point(this->rect().topLeft());
QRectF rect(QPointF(point.x()+2, point.y()), QSizeF(20,20));
rectItem = new MyRectItem(rect);
scene->addItem(rectItem);
point = QPointF(rectItem->boundingRect().topRight());
rect = QRectF(QPointF(point.x()+5,point.y()), QSizeF(20,20));
radiousRectItem = new MyRectRadiousItem(rect);
scene->addItem(radiousRectItem);
point = QPointF(radiousRectItem->boundingRect().topRight());
rect = QRectF(QPointF(point.x()+5,point.y()), QSizeF(20,20));
ellipseItem = new MyEllipseItem(rect);
scene->addItem(ellipseItem);
point = QPointF(ellipseItem->boundingRect().topRight());
rect = QRectF(QPointF(point.x()+5,point.y()), QSizeF(20,20));
textEditItem = new MyDockTextItem(rect);
scene->addItem(textEditItem);
view->setHorizontalScrollBarPolicy (Qt::ScrollBarAsNeeded);
view->setVerticalScrollBarPolicy (Qt::ScrollBarAsNeeded);
this->setWidget(view);
}
void MyOrganizationDockWidget::resizeEvent(QResizeEvent * event){
QPointF point(this->rect().topLeft());
rectItem->update(point.x(), point.y(), 20,20);
QDockWidget::resizeEvent(event);
}