PDA

View Full Version : QwtDial label



lvsteenson
20th December 2012, 16:57
Hi All,
I am struggling to put a label onto a QwtDial. Ideally I would like to have both the units inside the dial and then a separate label outside saying what the dial is showing. Is this possible? I have searched for quite a while though I have very little experience with GUIs so I maybe missing something obvious!

At the minute I have made a simple function that returns a dial object. Can anyone help with what to add to insert the labels I want?

EDIT: I am using Python

def create_dials(self, name, unit):

dial = Qwt.QwtDial()

dial.setWrapping(False)
dial.setReadOnly(True)
dial.setFixedSize(150,150)

dial.setOrigin(135.0)
dial.setScaleArc(0.0, 270.0)
dial.setRange(0.0, 240.0)
dial.setScale(-1, 2, 20)

dial.setNeedle(Qwt.QwtDialSimpleNeedle(
Qwt.QwtDialSimpleNeedle.Arrow,
True,
QColor(Qt.red),
QColor(Qt.gray).light(130)))

dial.setScaleOptions(Qwt.QwtDial.ScaleTicks | Qwt.QwtDial.ScaleLabel )
dial.setScaleTicks(0, 4, 8)


return dial

Uwe
21st December 2012, 08:17
Well the python bindings are for Qwt 5.2, let's see:

dial.setScale() calculates the scale ticks for you. When you need more control over the positions of the ticks you can assign them by dial.scaleDraw()->setScaleDiv().

The mapping of the tick positions to labels is done in QwtDialScaleDraw::label(). If you need something different as the numbers ( or you want some labels with special colors/fonts ) it has to be overloaded for a different mapping.

Ticks and label on the inner side of the scales are not possible. The reason for this limitation is simply that the code of the round scales is older than the dial class and was never extended.

Uwe