PDA

View Full Version : Qwt dial



Pvr
19th June 2018, 07:57
Hai
Can anyone please suggest me how to use drawscalecontents() method of qwt dial class to draw a dial. I don’t get any idea of passing values to this function. What values I should pass to this function. Can anyone post a sample code of this line. I stuck up with this issue.

Pvr

Uwe
19th June 2018, 08:34
QwtDial::drawScaleContents() is a hook to be overloaded, that allows the application code to draw whatever you want - the default implementation does nothing.

F.e.


class YourDial: public QwtDial
{
...

virtual drawScaleContents( QPainter *painter,
const QPointF &center, double radius ) const override
{
QRectF rect;
rect.setSize( 0.5 * radius, 0.5 * radius );
rect.moveCenter( center );

painter->setPen( Qt::black );
painter->setBrush( Qt::red ):

painter->drawRect( rect );
}
};Uwe

Pvr
19th June 2018, 19:39
Thanks for the reply. Iam using qwt with qtcreator so I have to call this method from mainwindow.cpp. I have seen this implementation in many places but I don’t know how to call this method from mainwindow. Kindly help me with code to call this function. The dial will get created only when this method is getting called rite? Thanks in advance

Uwe
21st June 2018, 14:26
Well this is a very basic question - but in short: you usually don't call those type of methods, it is called by the framework.

Uwe

Pvr
22nd June 2018, 17:34
Sorry I don’t understand I am using ROS for programming and qtcreator for GUI. Iam not able to create a dial using qwt. Can you pls share a line of code to use this method. There is an argument to this as ‘centre’ what should be the value for this. Pls reply me as early as possible