forked from magnocube/POV-Globe
-
Notifications
You must be signed in to change notification settings - Fork 0
/
customtext.cpp
62 lines (42 loc) · 1.41 KB
/
customtext.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
49
50
51
52
53
54
55
56
57
58
59
60
#include "customtext.h"
CustomText::CustomText()
{
x_location =0;
y_location =0;
width =200;
height =50;
color = Qt::red;
textString = "enter Text";
size = 10;
setFlag(ItemIsSelectable);
setFlag(ItemIsMovable);
}
QRectF CustomText::boundingRect() const
{
return QRectF(x_location,y_location,width,height);
}
void CustomText::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
QRectF rec = boundingRect();
QPen pen(color);
painter->setFont(font);
painter->rotate(rotation);
painter->setPen(pen);
painter->drawText(rec,textString,QTextOption());
}
void CustomText::newProperties(int size,int rotation ,QColor color,QFont font, QString text)
{
qDebug() << size << " " << rotation << " " << color.name() << " " << font.toString() ;
this->rotation = rotation;
this->color = color;
this->font = font;
this->textString = text;
emit updateGraphics();
}
void CustomText::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *e)
{
CustomText_Editor * myEditor = new CustomText_Editor(size,rotation ,color, font, textString); //dont forget to delete this pointer from the heap when the wondow closes
connect(myEditor,SIGNAL(propertyChanged(int,int,QColor,QFont,QString)),this,SLOT(newProperties(int,int,QColor,QFont,QString)));
myEditor->show();
//Todo,,, find a solution to removing the windows
}