Results 1 to 4 of 4

Thread: text inside QGraphicsEllipseItem

  1. #1

    Default text inside QGraphicsEllipseItem

    Hello,

    I create circles(or discs) on QGraphicsScene using QGraphicsEllipseItem. Now what I need is to number these circles. How can I use QPaint to drawtext on a QGraphicsEllipseItem ?? or is there any better way to number the circles ??

    I am using Qt 4.4

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: text inside QGraphicsEllipseItem

    Subclass QGraphicsEllipseItem and make it draw a numbered circle.

  3. #3

    Default Re: text inside QGraphicsEllipseItem

    Thanks Jacek,

    I am quite new to Qt. Can you point me an example for subclassing ?

  4. #4
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: text inside QGraphicsEllipseItem

    Qt Code:
    1. class myItem :public QGraphicsEllipseItem
    2. {
    3. public:
    4. paint ( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0 )
    5. {
    6.  
    7. painter->drawText() // Draw you text
    8. }
    9.  
    10. };
    To copy to clipboard, switch view to plain text mode 

    Hope this helps

Similar Threads

  1. Unhandled exception in qatomic
    By NewGuy in forum Qt Programming
    Replies: 14
    Last Post: 23rd July 2013, 09:49
  2. Problem pasting text into a QTextEdit
    By Spockmeat in forum Qt Programming
    Replies: 8
    Last Post: 14th March 2009, 14:36
  3. Match the text beetween two string
    By dreamer in forum Qt Programming
    Replies: 4
    Last Post: 20th May 2008, 14:48
  4. QTextEdit slow to insert text
    By thomaspu in forum Qt Programming
    Replies: 4
    Last Post: 10th January 2008, 12:05
  5. Editable text in QGraphicsView
    By wysota in forum Qt Programming
    Replies: 8
    Last Post: 24th February 2007, 15:30

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.