PDA

View Full Version : Draw Text inside a dial



sirop
24th May 2017, 15:14
Hello.

AttitudeIndicator class within the example "dials" show how to customize a QwtDialNeedle.

Thus one can get some free space within the dial to print the present angle value within the dial
if the space outside the dial is scarce.

I thought that something like:

void AttitudeIndicator::paintEvent( QPaintEvent *event )
{
QPainter painter(this);
painter.save();
painter.drawText(innerRect().center(),QString::num ber(value()));
painter.restore();
}

would help, but this paintEvent function only updates the text without repainting the dial itself.

Is there any elegant workaround for this?

Thanks.

Uwe
24th May 2017, 15:34
The SpeedoMeter class of the dials example does something similar.

Uwe

sirop
24th May 2017, 17:18
The SpeedoMeter class of the dials example does something similar.

Uwe

Yes, I looked at the SpeedoMeter class.
Adding


d_speedo->setLabel(QString::number(d_speedo->value()) + "km/h");

to the end of void CockpitGrid::changeSpeed() almost solves it,
it is only that the km/h "Label" gets updated only if the main (parent) widget is resized.

sirop
14th June 2017, 11:16
Just for the record:
QWT Dial, show unit (https://stackoverflow.com/a/43905148/4599792)