-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
41 lines (32 loc) · 1015 Bytes
/
main.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
#include <QApplication>
#include <QGraphicsScene>
#include <QGraphicsView>
#include <QtWidgets>
#include "colortank.h"
#include "colorcircle.h"
void test();
int main(int argc, char **argv)
{
QApplication a(argc, argv);
test();
return a.exec();
}
void test()
{
QGraphicsScene *scene = new QGraphicsScene(-200, -200, 400, 400);
QGraphicsView *view = new QGraphicsView(scene);
for (int i = 0; i < 10; ++i) {
ColorCircle *colorItem = new ColorCircle(QRandomGenerator::global()->generate());
colorItem->setPos(::sin((i * 6.28) / 10.0) * 150,
::cos((i * 6.28) / 10.0) * 150);
scene->addItem(colorItem);
}
ColorTank *tank = new ColorTank();
tank->setPos(0, 0);
scene->addItem(tank);
view->setRenderHint(QPainter::Antialiasing);
view->setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate);
view->setBackgroundBrush(QColor(230, 200, 167));
view->setWindowTitle("Color Picker");
view->show();
}