Results 1 to 3 of 3

Thread: QGraphicsItem: ignore scaling without ignoring rotations

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2009
    Posts
    62
    Thanks
    2
    Thanked 16 Times in 15 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QGraphicsItem: ignore scaling without ignoring rotations

    I would keep a list of all items that you don't want to scale, and then do this for scaling:

    Qt Code:
    1. QList<QGraphicsItem*> nonScalingItems;
    2.  
    3. // ...
    4.  
    5. view->scale(scaleX, scaleY);
    6. foreach (QGraphicsItem* item, nonScalingItems)
    7. {
    8. item->scale(1.0/scaleX, 1.0/scaleY);
    9. }
    To copy to clipboard, switch view to plain text mode 

  2. The following user says thank you to shentian for this useful post:

    Lodorot (4th July 2009)

  3. #2
    Join Date
    Mar 2011
    Posts
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QGraphicsItem: ignore scaling without ignoring rotations

    Hi

    What I've done to solve this problem
    Note: myGraphicsView->initialScale is != to 1.f in my application but for most of code, you can replaced it by 1;
    Qt Code:
    1. MyItem::MyItem(QGraphicsView* _myGraphicsView )
    2. {
    3. myGraphicsView = _myGraphicsView;
    4. connect(myGraphicsView ,SIGNAL(scaleChanged(float)),this,SLOT(parentScaleChanged(float)));
    5. }
    6.  
    7. void MyItem::parentScaleChanged(float newScale)
    8. {
    9. setScale(myGraphicsView->initialScale/newScale);
    10. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Scale size of QGraphicsItem without scaling pen width
    By Lodorot in forum Qt Programming
    Replies: 1
    Last Post: 25th May 2009, 00:18
  2. Ignoring scaling graphics view/scale
    By maverick_pol in forum Qt Programming
    Replies: 1
    Last Post: 7th August 2007, 17:44
  3. Replies: 6
    Last Post: 30th April 2007, 23:59
  4. how to corss compile for windows in Linux
    By safknw in forum Qt Programming
    Replies: 24
    Last Post: 13th May 2006, 05: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
  •  
Qt is a trademark of The Qt Company.