##// END OF EJS Templates
Fix chart resize for rotated QChartViews....
Miikka Heikkinen -
r2500:f8aaf8b5fc37
parent child
Show More
@@ -257,9 +257,21 void QChartViewPrivate::setChart(QChart *chart)
257 257 resize();
258 258 }
259 259
260 const qreal rad2deg(57.2957795);
261
260 262 void QChartViewPrivate::resize()
261 263 {
262 m_chart->resize(q_ptr->size());
264 // Flip chart width and height if the view has been rotated
265 // more than 45 degrees from the horizontal so it fits better into the view.
266 qreal angle = acos(q_ptr->transform().m11()) * rad2deg;
267 QSize chartSize = q_ptr->size();
268
269 if (angle > 45.0 && angle < 135.0) {
270 chartSize.setHeight(q_ptr->size().width());
271 chartSize.setWidth(q_ptr->size().height());
272 }
273
274 m_chart->resize(chartSize);
263 275 q_ptr->setMinimumSize(m_chart->minimumSize().toSize());
264 276 q_ptr->setSceneRect(m_chart->geometry());
265 277 }
General Comments 0
You need to be logged in to leave comments. Login now