Results 1 to 3 of 3

Thread: QGraphicsRectItem with text

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2013
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QGraphicsRectItem with text

    Hi!

    I'm very new at Qt and I need to be able to write text in a QGraphicsRectItem. I tried making a class inheriting from QGraphicsRectItem and QGraphicsTextItem and then use setPlainText but the text won't show up. What do I have to do and how?
    I'm using Python.

    Thank you very much!

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QGraphicsRectItem with text

    Place a QGraphicsTextItem as child of QGraphicsRectItem.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    May 2013
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QGraphicsRectItem with text

    Thank you

    New question: how can I manage to display the text (which will just be a number) in the center of the QGraphicsRectItem? I can't seem to find any alignment method in the QGraphicsTextItem class.

    Thank you again!

Similar Threads

  1. QGraphicsRectItem animation
    By mvbhavsar in forum Newbie
    Replies: 2
    Last Post: 30th August 2011, 11:00
  2. Take a screenshot of a QGraphicsRectItem
    By yazwas in forum Qt Programming
    Replies: 1
    Last Post: 12th October 2009, 13:14
  3. QGraphicsRectItem with text
    By ttvo in forum Qt Programming
    Replies: 1
    Last Post: 26th August 2009, 19:53
  4. QGraphicsRectItem
    By c_srikanth1984 in forum Qt Programming
    Replies: 1
    Last Post: 29th July 2009, 09:04
  5. How can I use QGraphicsRectItem?
    By learning_qt in forum Qt Programming
    Replies: 3
    Last Post: 14th January 2009, 10:00

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
  •  
Qt is a trademark of The Qt Company.