Results 1 to 4 of 4

Thread: Draw Text inside a dial

  1. #1
    Join Date
    Apr 2012
    Posts
    13
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question Draw Text inside a dial

    Hello.

    AttitudeIndicator class within the example "dials" show how to customize a QwtDialNeedle.

    Thus one can get some free space within the dial to print the present angle value within the dial
    if the space outside the dial is scarce.

    I thought that something like:
    Qt Code:
    1. void AttitudeIndicator::paintEvent( QPaintEvent *event )
    2. {
    3. QPainter painter(this);
    4. painter.save();
    5. painter.drawText(innerRect().center(),QString::number(value()));
    6. painter.restore();
    7. }
    To copy to clipboard, switch view to plain text mode 

    would help, but this paintEvent function only updates the text without repainting the dial itself.

    Is there any elegant workaround for this?

    Thanks.

  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: Draw Text inside a dial

    The SpeedoMeter class of the dials example does something similar.

    Uwe

  3. The following user says thank you to Uwe for this useful post:

    sirop (24th May 2017)

  4. #3
    Join Date
    Apr 2012
    Posts
    13
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Draw Text inside a dial

    Quote Originally Posted by Uwe View Post
    The SpeedoMeter class of the dials example does something similar.

    Uwe
    Yes, I looked at the SpeedoMeter class.
    Adding
    Qt Code:
    1. d_speedo->setLabel(QString::number(d_speedo->value()) + "km/h");
    To copy to clipboard, switch view to plain text mode 
    to the end of void CockpitGrid::changeSpeed() almost solves it,
    it is only that the km/h "Label" gets updated only if the main (parent) widget is resized.

  5. #4
    Join Date
    Apr 2012
    Posts
    13
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Draw Text inside a dial

    Just for the record:
    QWT Dial, show unit

Similar Threads

  1. Draw each curve scale inside plot/canvas
    By phenoboy in forum Qwt
    Replies: 5
    Last Post: 15th January 2016, 14:47
  2. Draw with OPenGL inside QMAinWindow
    By zulunation in forum Newbie
    Replies: 10
    Last Post: 12th November 2014, 12:35
  3. Replies: 10
    Last Post: 11th February 2011, 00:31
  4. QLineEdit, draw only text
    By Radagast in forum Qt Programming
    Replies: 1
    Last Post: 28th March 2009, 12:15
  5. How can I draw needle for dial in Qwt
    By validator in forum Qwt
    Replies: 6
    Last Post: 3rd February 2008, 21:27

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.