In any case now I fixed as I told, intercepting valueChanged and outputing the right value.
Now I tried to implement the other point, using text label:
public:
void drawLabel
(QPainter *painter,
double value
) const {
QwtText label
(decade_helper
::format (value
));
label.setRenderFlags(0);
label.
setLayoutAttribute(QwtText::MinimumLayout);
label.textSize(painter->font ());
if (label.isEmpty ()) return;
const int tval = map ().transform (value);
double startAngle = map ().p1 ();
if ((tval > startAngle + 359 * 16) || (tval < startAngle - 359 * 16)) return;
const QSize sz
= label.
textSize (painter
->font
());
const double arc = tval / 16.0 / 360.0 * 2 * M_PI;
const int x = center ().x () + qRound ((radius + sz.width () / 2.0) * sin (arc));
const int y = center ().y () - qRound ((radius + sz.height () / 2.0) * cos (arc));
const QRect r
(x
- sz.
width () / 2, y
- sz.
height () / 2, sz.
width (), sz.
height ());
label.draw(painter, r);
}
};
class knob125_scale: public QwtRoundScaleDraw {
public:
void drawLabel(QPainter *painter, double value) const {
QwtText label(decade_helper::format (value));
label.setRenderFlags(0);
label.setLayoutAttribute(QwtText::MinimumLayout);
label.textSize(painter->font ());
if (label.isEmpty ()) return;
const int tval = map ().transform (value);
double startAngle = map ().p1 ();
if ((tval > startAngle + 359 * 16) || (tval < startAngle - 359 * 16)) return;
double radius = QwtRoundScaleDraw::radius ();
if (hasComponent(QwtAbstractScaleDraw::Ticks) || hasComponent(QwtAbstractScaleDraw::Backbone)) radius += spacing ();
if (hasComponent(QwtAbstractScaleDraw::Ticks)) radius += majTickLength ();
const QSize sz = label.textSize (painter->font ());
const double arc = tval / 16.0 / 360.0 * 2 * M_PI;
const int x = center ().x () + qRound ((radius + sz.width () / 2.0) * sin (arc));
const int y = center ().y () - qRound ((radius + sz.height () / 2.0) * cos (arc));
const QRect r(x - sz.width () / 2, y - sz.height () / 2, sz.width (), sz.height ());
label.draw(painter, r);
}
};
To copy to clipboard, switch view to plain text mode
Which is a cut/paste from the corrisponding method of QwtRoundScaleDraw, using decade_helper which is a tool to substitute zeroes with scale (0.03 becomes 30m) .
This solution is not very clean, but unfortunatelly there is no simple way to have ticks with other than doubles... 
It works but I have some points with the total widget size.
Bookmarks