##// END OF EJS Templates
Change sizeHint of vertical axis, caculate width based on each label
Michal Klocek -
r2336:03ff7a7fe0a8
parent child
Show More
@@ -97,7 +97,6 QSizeF ChartDateTimeAxisX::sizeHint(Qt::SizeHint which, const QSizeF &constraint
97 97 return sh;
98 98 }
99 99
100
101 100 switch (which) {
102 101 case Qt::MinimumSize:{
103 102 int count = qMax(ticksList.last().count(),ticksList.first().count());
@@ -94,10 +94,18 QSizeF ChartDateTimeAxisY::sizeHint(Qt::SizeHint which, const QSizeF &constraint
94 94 qreal width = 0;
95 95 qreal height = 0;
96 96
97
97 98 if(ticksList.empty()){
98 99 return sh;
99 100 }
100 101
102 int labelWidth = 0;
103
104 foreach(const QString& s, ticksList)
105 {
106 labelWidth=qMax(fn.width(s),labelWidth);
107 }
108
101 109 switch (which) {
102 110 case Qt::MinimumSize: {
103 111 width = fn.boundingRect("...").width() + labelPadding();
@@ -108,8 +116,7 QSizeF ChartDateTimeAxisY::sizeHint(Qt::SizeHint which, const QSizeF &constraint
108 116 break;
109 117 }
110 118 case Qt::PreferredSize: {
111 int count = qMax(ticksList.first().count() , ticksList.last().count());
112 width = count*fn.averageCharWidth() + labelPadding() + 2; //two pixels of tolerance
119 width = labelWidth + labelPadding() + 2; //two pixels of tolerance
113 120 width += base.width();
114 121 height = fn.height() * ticksList.count();
115 122 height = qMax(height,base.height());
@@ -95,10 +95,11 QSizeF ChartValueAxisY::sizeHint(Qt::SizeHint which, const QSizeF &constraint) c
95 95 qreal width = 0;
96 96 qreal height = 0;
97 97
98 int count = 1;
98 int labelWidth = 0;
99 99
100 if(!ticksList.empty()){
101 count = qMax(ticksList.last().count(),ticksList.first().count());
100 foreach(const QString& s, ticksList)
101 {
102 labelWidth=qMax(fn.width(s),labelWidth);
102 103 }
103 104
104 105 switch (which) {
@@ -112,7 +113,7 QSizeF ChartValueAxisY::sizeHint(Qt::SizeHint which, const QSizeF &constraint) c
112 113 }
113 114 case Qt::PreferredSize:
114 115 {
115 width = count*fn.averageCharWidth() + labelPadding() + 2; //two pixels of tolerance
116 width = labelWidth + labelPadding() + 2; //two pixels of tolerance
116 117 width += base.width();
117 118 height = fn.height() * ticksList.count();
118 119 height = qMax(height,base.height());
General Comments 0
You need to be logged in to leave comments. Login now