Results 1 to 5 of 5

Thread: AddText to QRect on QGraphicsView

  1. #1
    Join Date
    Dec 2010
    Posts
    12
    Thanks
    1
    Qt products
    Qt3 Qt4 PyQt3 PyQt4
    Platforms
    Unix/X11 Windows

    Question AddText to QRect on QGraphicsView

    I am trying to add text on different Qrects I have plotted on the QGraphicsScene (added to QGraphicsView).
    I have enabled horizontal zooming of the scene on mousewheel motion. I could add the text to QGraphicsScene but, when I zoom the scene the Text also gets zoomed.
    I want to keep the Text size as it is but the text should shift (along with corresponding QRect ) according to the zooming factor ...

    I have attached 2 images here ....initial.jpgzoomed.jpg



    any suggestions ??

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

    Default Re: AddText to QRect on QGraphicsView

    Set the ItemIgnoresTransformations flag for your text items.
    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
    Dec 2010
    Posts
    12
    Thanks
    1
    Qt products
    Qt3 Qt4 PyQt3 PyQt4
    Platforms
    Unix/X11 Windows

    Default Re: AddText to QRect on QGraphicsView

    thanx...
    I have one more query...
    As you know , I have put a text on each QRect..
    now,what I want is - >
    initially I want only some portion of text to be visible as the QRect is smaller in size..
    On zooming horizontally , the text should get completed according to the size of QRect...
    How can I get this ?
    currently the text is going outside the QRect before zooming....
    attaching screenshots ...
    text1.jpgzoomedText.jpg

  4. #4
    Join Date
    Dec 2010
    Posts
    12
    Thanks
    1
    Qt products
    Qt3 Qt4 PyQt3 PyQt4
    Platforms
    Unix/X11 Windows

    Question Re: AddText to QRect on QGraphicsView

    I could find one method to do this....
    using QGraphicsTextItem::setTextWidth();
    but the problem is, initially the text is broken into many line which I can't hide...
    so the broken text lines show up below the corresponding QRect....


    attaching screenshot...!!

    newtext1.jpg

    new_zoomedtext.jpg

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

    Default Re: AddText to QRect on QGraphicsView

    Use the level-of-detail information that you can query for in the item's paint() routine. Or use QFontMetrics to calculate the elided text based on the real rectangle occupied by the item. Which to choose depends on what you actually want to do.
    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.


Similar Threads

  1. Right justify QPainterPath addText
    By GimpMaster in forum Qt Programming
    Replies: 5
    Last Post: 20th January 2011, 20:18
  2. Get QRect of a widget using mouseevent
    By arpspatel in forum Qt Programming
    Replies: 9
    Last Post: 9th March 2010, 04:19
  3. difference of QRect and QRectF
    By gbmtoday in forum Newbie
    Replies: 1
    Last Post: 14th January 2010, 22:52
  4. Replies: 11
    Last Post: 17th January 2009, 09:06
  5. Move QCompleter on QRect x,y
    By patrik08 in forum Qt Programming
    Replies: 1
    Last Post: 8th August 2007, 10:33

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.