PDA

View Full Version : How can I draw needle for dial in Qwt



validator
3rd February 2008, 01:41
I write this code ( QwtDial *d=new QwtDial(ui.label);) I create a dial but there is no needle .I look end I see that drawNeedle method is protected .How can I draw a needle for qwtdial .Please can you write sample code

jacek
3rd February 2008, 15:41
You can set the needle using QwtDial::setNeedle() method.

validator
3rd February 2008, 16:05
I use setNeedle Method but this method want QwtDialNeedle object but QwtDialNeedle is abstract class.How can I do this .

I write this code but I take access violation error.


ui.setupUi(this);
QwtDial *d=new QwtDial(ui.label);
d->setScaleArc(30,330);
d->setScale(100,10,60);
/*d->setOrigin(100);*/
d->setLineWidth(15);
d->setValue(5);
d->setWrapping(false);
QwtDialNeedle * nd;
d->setNeedle(nd);

jpn
3rd February 2008, 17:06
I use setNeedle Method but this method want QwtDialNeedle object but QwtDialNeedle is abstract class.How can I do this .

I write this code but I take access violation error.


QwtDialNeedle * nd;
d->setNeedle(nd);

Yes, because you pass an uninitialized pointer which points to some random memory garbage. Instantiate one of QwtDialNeedle (http://qwt.sourceforge.net/class_qwt_dial_needle.html) non-abstract subclasses. From the docs you'll see which classes inherit QwtDialNeedle.

validator
3rd February 2008, 17:46
yes I examine docs but I can not understand .if you have time , can you write an example.
Thanks

jacek
3rd February 2008, 18:26
yes I examine docs but I can not understand .
Use QwtCompassWindArrow, QwtDialSimpleNeedle or QwtCompassMagnetNeedle instead and make sure you create the needle object using new operator.

validator
3rd February 2008, 21:27
Thank you .I did