Skip to content

Commit c44f9d1

Browse files
committed
Fixed Point graphic bug? v3
1 parent 56b26da commit c44f9d1

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

output_widget.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,10 @@ void OutputWidget::drawItem(Settings data){
8080
font.setPointSize(1);
8181

8282
// Compiler forced me to declare these up here for some reason
83-
QRectF bRect;
84-
double dx;
85-
double dy;
83+
QPointF origin;
84+
QRectF bRect;
85+
qreal dx;
86+
qreal dy;
8687

8788
Settings::Type name = data.itemType;
8889

@@ -101,8 +102,9 @@ void OutputWidget::drawItem(Settings data){
101102
m_item->setScale(data.scale);
102103

103104
// Translate item center-point to scene origin
104-
dx = 0.0 - (m_item->boundingRect().center().x());
105-
dy = 0.0 - (m_item->boundingRect().center().y());
105+
origin = m_item->mapFromScene(0.0, 0.0);
106+
dx = origin.x() - (m_item->boundingRect().center().x());
107+
dy = origin.y() - (m_item->boundingRect().center().y());
106108
m_item->moveBy(dx, dy);
107109

108110
// Re-assign item origin used for transformations
@@ -134,11 +136,12 @@ void OutputWidget::drawItem(Settings data){
134136
bRect = QRectF(0.0, 0.0, data.size, data.size);
135137

136138
// Create an Ellipse bounded by the QRectF and add to scene
137-
m_item = m_scene->addEllipse(bRect, pen, QBrush(Qt::SolidPattern));
139+
m_item = m_scene->addEllipse(bRect, pen, pen.brush());
138140

139141
// Translate item center-point to scene origin
140-
dx = 0.0 - (m_item->boundingRect().center().x());
141-
dy = 0.0 - (m_item->boundingRect().center().y());
142+
origin = m_item->mapFromScene(0.0, 0.0);
143+
dx = origin.x() - (m_item->boundingRect().center().x());
144+
dy = origin.y() - (m_item->boundingRect().center().y());
142145
m_item->moveBy(dx, dy);
143146

144147
// Translate item center-point to input coordinates

0 commit comments

Comments
 (0)