PDA

View Full Version : How to add label in speedometer



cooper
29th July 2011, 05:58
Hi everyone,

Currently I am designing a speedometer in Qt. I did read the example which come with Qwt installation package. However, I didn't create the this widget manually, but created it by dragging the Qwtdial widget into my dialog.

Here is my code:


ui->Dial->setScaleArc(0.0, 270.0);
ui->Dial->scaleDraw()->setSpacing(1);
ui->Dial->setScaleTicks(0, 2, 4);
ui->Dial->setRange(0, 160);
ui->Dial->setScale(1, 2, 20);
QwtDialSimpleNeedle *needle = new QwtDialSimpleNeedle(
QwtDialSimpleNeedle::Arrow, true, Qt::red,
QColor(Qt::gray).light(130));
ui->Dial->scaleDraw()->setPenWidth(1);
ui->Dial->setNeedle(needle);


My question is how i can add label at the bottom of speedometer?

In the example, it used


SpeedoMeter::drawScaleContents(QPainter *painter,
const QPoint &center, int radius) const

but i don't know how to use in my code.

thanks in advance.

Uwe
29th July 2011, 07:50
The code for the label in the speedometer is broken in Qwt 6.0.0 ( its a QPointF no QPoint ). Look at the code in SVN trunk.

Uwe

cooper
1st August 2011, 01:15
Hi Uwe,

Thanks for your reply. I am using Qwt 5.2.1.
Does the label code in this version is broken too?
Can you give me any other hint please?

Cheers

Uwe
1st August 2011, 09:31
Thanks for your reply. I am using Qwt 5.2.1.
Does the label code in this version is broken too?
No - but you can simply start the application to see if it works.


Can you give me any other hint please?
Not at all - the code shows you what to do in a couple of simple lines.

Uwe