Results 1 to 6 of 6

Thread: Problems with QGraphicsItems

  1. #1
    Join Date
    Jan 2007
    Posts
    81
    Thanks
    17
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Problems with QGraphicsItems

    Hello all,

    So I'm now having some troubles with QGraphicsItems....specifically when I want to print QGraphicsTextItem. When I print the text to my scene, I can't see it because the scale of the scene shrinks the text too much. So when use scale to enlarge the scene, the text becomes larger...but then too large....
    Any ideas how to make this text a static size, just like my QGraphicsLineItem, which always stays of pixel width one regards of the scale from the scene?

    Second problem is when I draw a QGraphicsLineItem between two points and it is either _perfectly_ horizontal or vertical, then it will not disappear unless I minimize the window.... this is my code...

    Qt Code:
    1. if(showMeasureLine){
    2. m_MeasureLine->show();
    3. m_MeasureLine->setLine(QLineF(m_measureDistStartPoint,m_currentMousePos));
    4. }
    5. else{
    6. MeasureLine->hide();
    7. MeasureLine->update();
    8. }
    To copy to clipboard, switch view to plain text mode 

    this code is within mouseMoveEvent(QMouseEvent *event)....
    it works for when the line is diagonal etc. but not when 90, 180, 270 or 360 degrees

  2. #2
    Join Date
    Jan 2006
    Location
    Norway
    Posts
    124
    Thanked 38 Times in 30 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Problems with QGraphicsItems

    You're probably looking for ItemIgnoresTransformations, a new flag appearing in the upcoming Qt 4.3. It ensures that the item stays the same size also when you zoom in or out.
    Last edited by Bitto; 24th April 2007 at 17:43. Reason: typo
    Bitto / Andreas Aardal Hanssen - andreas dot aardal dot hanssen at nokia
    Nokia Software Manager, Qt Development

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

    JonathanForQT4 (25th April 2007)

  4. #3
    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: Problems with QGraphicsItems

    Qt Code:
    1. if(showMeasureLine)
    2. { m_MeasureLine->show();
    3. m_MeasureLine->setLine(QLineF(m_measureDistStartPoint,m_currentMousePos));
    4. }
    To copy to clipboard, switch view to plain text mode 
    did u try caling update after setting the line ??

  5. #4
    Join Date
    Jan 2007
    Posts
    81
    Thanks
    17
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Problems with QGraphicsItems

    hey, thanks for your post Andreas!! I'm looking forward to when 4.3 is released, unfortunately I can't use 4.3, do you have any suggestions about how I could do this until 4.3 comes out? maybe putting a widget over the viewport or something and print on the widget?
    I've tried this, but had troubles centering the widget/keeping it the same size as the viewport from the QGraphicsView and being able to click on the overlaying widget and having the viewport pick it up.
    Any clues as to when 4.3 will be released?
    in any case, thanks again

    aamer4yu, tried calling update after this line, but that doesn't work. I am surprised because it should be the following that should cause it to disappear.
    m_MeasureLine->hide();
    m_MeasureLine->update();

    Any other ideas?

    another eidt://I have just tried adding the item each time to the scene and removing it from the scene each time....still doesn't work...
    Last edited by JonathanForQT4; 25th April 2007 at 10:06. Reason: typo

  6. #5
    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: Problems with QGraphicsItems

    can we see the minimal code that causes the problem ??

  7. #6
    Join Date
    Jan 2007
    Posts
    81
    Thanks
    17
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Problems with QGraphicsItems

    um, the code I have posted is the only time I do anything with m_Measureline, so this must be the code the causes the problem.... the only other place I mention anything is in the constructor: m_MeasureLine = new QGraphicsLineItem(0, m_mainScene);

    I'm starting to guess that when the line is vertical or horizontal the Qt background code stores it on the scene in a different way and that's why it stays there even when I do a refresh....so...dare I say a bug with Qt!!

Similar Threads

  1. Performance problems with overlapping qgraphicsitems
    By brjames in forum Qt Programming
    Replies: 13
    Last Post: 4th May 2008, 21:42
  2. Replies: 2
    Last Post: 8th March 2007, 22:22
  3. Problems building mysql plugin for Qt 4.1.2 on windows XP
    By Philip_Anselmo in forum Installation and Deployment
    Replies: 3
    Last Post: 17th May 2006, 15:38
  4. Canvas problems
    By Tommytrojan in forum Qt Programming
    Replies: 22
    Last Post: 9th May 2006, 16:46
  5. QT4 Plugins - problems, problems
    By NormanDunbar in forum Qt Programming
    Replies: 6
    Last Post: 9th May 2006, 15:39

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.