Results 1 to 4 of 4

Thread: QwtDial backbone radius problem

  1. #1
    Join Date
    Oct 2017
    Location
    Boston, MA
    Posts
    2
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Unhappy 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.
    inner_angle_deg.PNG

    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

  2. #2
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,309
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default 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

  3. #3
    Join Date
    Oct 2017
    Location
    Boston, MA
    Posts
    2
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default 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

  4. #4
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,309
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QwtDial backbone radius problem

    Quote Originally Posted by cmschroeder View Post
    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

Similar Threads

  1. Problem with border radius on my QHeaderView
    By alienufo in forum Qt Programming
    Replies: 3
    Last Post: 11th June 2015, 07:22
  2. Replies: 7
    Last Post: 10th July 2013, 14:32
  3. QwtPolarPlot radius scale
    By brutus35 in forum Qwt
    Replies: 2
    Last Post: 24th February 2011, 18:46
  4. RADIUS SERVER and Qt 4.7
    By rmagro in forum Qt Programming
    Replies: 0
    Last Post: 18th November 2010, 15:51
  5. QWTDial problem
    By zaferaltug in forum Qwt
    Replies: 2
    Last Post: 20th November 2008, 16:40

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.