Results 1 to 6 of 6

Thread: Number inside the circle

  1. #1
    Join Date
    Sep 2010
    Posts
    16
    Qt products
    Qt4
    Platforms
    Windows

    Default Number inside the circle

    Hello

    I have created a circle, like this example in http://doc.trolltech.com/4.7/graphic...sticnodes.html.

    Now, I want to insert number inside the circle, as:


    How can add number inside the circle ??
    Thank you
    Last edited by Jeneo W.; 4th December 2010 at 20:35.

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Number inside the circle

    Congratulations. Was there a question?

  3. #3
    Join Date
    Sep 2010
    Posts
    16
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Number inside the circle

    Quote Originally Posted by ChrisW67 View Post
    Was there a question?
    How can add number inside the circle ??

  4. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Number inside the circle

    QPainter::drawText() in the Node::paint() method would be a good starting point.
    Last edited by ChrisW67; 4th December 2010 at 20:49.

  5. #5
    Join Date
    Sep 2010
    Posts
    16
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Number inside the circle

    Is there a way to minimize the size of the font in the QPainter::drawText() ??

    Thank

  6. #6
    Join Date
    Dec 2009
    Posts
    128
    Thanks
    7
    Thanked 14 Times in 14 Posts
    Platforms
    Unix/X11 Windows

    Default Re: Number inside the circle

    a good way is to use the same QRect or QRectF to draw the circle
    Qt Code:
    1. QPainter::drawEllipse(QRectF)
    To copy to clipboard, switch view to plain text mode 
    and to draw the text
    Qt Code:
    1. QPainter::drawText(QRectF,AlignCenter,"text")
    To copy to clipboard, switch view to plain text mode 

    To change font's size, use QFont::setPointSize() or QFont::setPointSizeF()

Similar Threads

  1. draw a circle
    By NewLegend in forum Qt Programming
    Replies: 3
    Last Post: 13th October 2010, 16:01
  2. Coloring Circle
    By Jeneo W. in forum Qt Programming
    Replies: 1
    Last Post: 11th October 2010, 04:39
  3. how to draw a circle on a frame in Qt-4
    By grsandeep85 in forum Qt Programming
    Replies: 1
    Last Post: 16th September 2009, 08:05
  4. How to draw a special circle pie
    By parnedo in forum Qt Programming
    Replies: 7
    Last Post: 3rd July 2009, 15:25
  5. help regarding circle
    By jjbabu in forum Qt Programming
    Replies: 2
    Last Post: 20th September 2007, 10:23

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.