1 Attachment(s)
QwtDial backbone radius problem
I have created several gauges using QwtDial, but the default backbone arc and needle length are quite small relative to the surrounding frame.
Attachment 12603
After examining the source code, I found the QwtDial constructor always sets the associated QwtRoundScaleDraw object's radius to zero. So, I tried getting the QwtRoundScaleDraw object after a dial is created and setting a new radius. This had no effect. Examining the QwtRoundScaleDraw::extent() method, I found it did not include the radius in the QwtAbstractScaleDraw::Backbone component clause.
As an experiment, I tried adding the radius to the QwtRoundScaleDraw::extent() method and rebuilding the Qwt library. This allowed me to change the backbone radius as described above, but the ticks and labeling are not resized correctly; they are now inside the backbone radius instead of outside.
I've noticed the dial examples don't appear to use a backbone, so I am wondering if this is an issue that has been missed in testing the QwtDial functionality?
Kind regards,
Curt
Re: QwtDial backbone radius problem
Well the radius gets automatically adjusted in QwtDial::drawContents, It depends on the rectangle being calculated in QwtDial::scaleInnerRect, what is a virtual method that can be overloaded.
The default implementation of the extent should somehow depend on the space needed for the tick labels. I guess it is made for a tick label that needs more space - but to find out more you would need to use your debugger ( or upload source code for a small compilable demo ).
Uwe
Re: QwtDial backbone radius problem
QwtDial::scaleInnerRect() uses the extent from QwtDial::scaleDraw() plus a small margin to define the +/- rect:
int scaleDist = qCeil( sd->extent( font() ) );
scaleDist++; // margin
rect.adjust( scaleDist, scaleDist, -scaleDist, -scaleDist );
QwtDial::scaleDraw() returns the abstractScaleDraw() inherited from QwtAbstractSlider, which is in turn inherited from QwtAbstractScale, but cast to QwtRoundScaleDraw.
QwtDial::scaleInnerRect() casts the pointer returned by scaleDraw() back to QwtAbstractScaleDraw.
The extent() method in QwtAbstractScaleDraw is virtual and defaults to zero:
virtual double extent( const QFont &font ) const = 0;
I believe this means that QwtDial::scaleInnerRect() is not using QwtRoundScaleDraw::extent() and is possibly a bug.
Curt
Re: QwtDial backbone radius problem
Quote:
Originally Posted by
cmschroeder
The extent() method in QwtAbstractScaleDraw is virtual and defaults to zero:
virtual double extent( const QFont &font ) const = 0;
I believe this means that QwtDial::scaleInnerRect() is not using QwtRoundScaleDraw::extent() and is possibly a bug.
No, this is not how virtual methods work. If the object is a QwtRoundScaleDraw it doesn_t matter that you are calling the extent method from a pointer to its base class.
Uwe