Results 1 to 2 of 2

Thread: Trying to use single pixmap in two Scenes.

  1. #1
    Join Date
    Jun 2009
    Posts
    33
    Thanks
    5
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Trying to use single pixmap in two Scenes.

    I have generated a QPixmap and have added it to my main graphicsview via a subclass of QGraphicsScene.

    What I want is to take that same pixmap and use it in my mini map (smaller graphicsview similar to the first). The smaller view uses the standard QGraphicsScene.

    I have the Pixmap and have called QGraphicsPixmapItem *pixItem = scene->addPixmap(myPixmap);

    Question will this alone scale the pixmap to properly fit in the scene?
    How about the position? Should I need to map the pixmap's position or offset?

    almost there but still needing help,


    Spawn9997

  2. #2
    Join Date
    Jun 2009
    Posts
    33
    Thanks
    5
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Trying to use single pixmap in two Scenes.

    Hey all,

    Nevermind. My problem was not using one pixmap but trying to draw a QGraphicsPixmapItem in the scene where I wanted and at the correct size.
    I decided to subclass the regular QGraphicsItem and attach a pixmap to it. Then draw that map in my reimplemented paint function. That way I could use the QGraphicsItem::boundingRect() as follows:

    Qt Code:
    1. painter->drawPixmap(this->boundingRect().toRect(),*(this->pm));
    To copy to clipboard, switch view to plain text mode 

    where
    this->pm
    is a pointer to my QPixmap.
    This way the pixmap is forced to fit in my item. I just set the boundingRect() to the size of my scene. (minimap)


    spawn9997
    sw developer

Similar Threads

  1. Graphics View and the Pixmap
    By spawn9997 in forum Qt Programming
    Replies: 2
    Last Post: 26th June 2009, 23:12
  2. Performance problems with small pixmap
    By RThaden in forum Qt Programming
    Replies: 4
    Last Post: 9th July 2008, 16:14
  3. finding maximum scaling of a pixmap
    By babu198649 in forum Newbie
    Replies: 1
    Last Post: 31st March 2008, 15:32
  4. empty pixmap as a QLabel
    By tommy in forum Qt Programming
    Replies: 16
    Last Post: 11th December 2007, 22:15
  5. KDE/QWT doubt on debian sarge
    By hildebrand in forum KDE Forum
    Replies: 13
    Last Post: 25th April 2007, 07:13

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.