Results 1 to 8 of 8

Thread: [SOLVED] Painting QGraphicsItem constant size

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2010
    Posts
    55
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    9

    Default [SOLVED] Painting QGraphicsItem constant size

    I've created a very simple QGraphicsItem (currently just draws a box) that I'd like to draw the same size each time regardless of zoom level.

    What I mean is, if I add two of these items to my scene

    Qt Code:
    1. scene->addItem(new MyCustomItem());
    2. scene->addItem(new MyCustomItem());
    3. scene->items()[0].setPos(-10, 0);
    4. scene->items()[1].setPos(10, 0);
    To copy to clipboard, switch view to plain text mode 

    then start zooming in and out, obviously the item sizes will change depending on zoom level.
    What I'd like to do is keep the item sizes visually the same size, for example, the box would be 10 pixels wide on the user's screen, but the zoom still has an effect, i.e. zooming in will make the items appear farther apart.

    Is there an easy way to do this?
    Last edited by JovianGhost; 20th March 2010 at 19:21.

Similar Threads

  1. Replies: 7
    Last Post: 21st March 2010, 03:11
  2. get qgraphicsitem size
    By rogerholmes in forum Newbie
    Replies: 10
    Last Post: 18th February 2010, 05:04
  3. Scale size of QGraphicsItem without scaling pen width
    By Lodorot in forum Qt Programming
    Replies: 1
    Last Post: 25th May 2009, 00:18
  4. Font size calculation when painting in a QImage
    By Ishark in forum Qt Programming
    Replies: 3
    Last Post: 15th July 2007, 22:22
  5. Force the painting of a QGraphicsItem
    By fabietto in forum Qt Programming
    Replies: 3
    Last Post: 2nd July 2007, 21:28

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.