Results 1 to 3 of 3

Thread: Graphics View and the Pixmap

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

    Default Graphics View and the Pixmap

    Hello all,

    I have read some interesting things about QGraphicsView and how to add items and pixmaps. I have not see this exact issue tackled...

    I have a main view, QGraphicsView subclass, and I have a secondary view which is also a subclass of the graphics view. I have a scene that changes and has selectable items on it; So what I need is for the secondary view to act as a mini map. This mini map is supposed to have a 'picture' of the main view's scene (background image) and a rectangle that represents the view area of the main view. The rectangle is attached to the view such that moving the main view will move the rectangle in the secondary view and vice versa.
    I have everything taken care of and works like I want it except I cannot get the image to display in the mini map. I have tried setting the background but cannot find a way to make the background show 1 solid image; I also, have tried adding a pixmap but because I set the bounding Rect on both scenes when I add the pixmap it is too small to be of use.

    Example scene coordinates, because of the data I'm using, are on the order of 600,000 and dimensions are 7000-16000.

    Now the view itself is only of size 290x180 or something like that; so I don't think the pixmap should need to be so large.

    I know the coordinate system is my nemesis!!


    The question... how to get my pixmap (pixmapgraphicsitem) to fill the view?



    sw developer (first go at Qt)

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

    Default Re: Graphics View and the Pixmap

    I suggest you override QGraphicsView::drawBackground to draw the image.

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

    spawn9997 (26th June 2009)

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

    Default Re: Graphics View and the Pixmap

    Thank you for your response. I had tried this already but as I am new to Qt, it seems I needed a few more days (and attempts) to understand how to do this.
    I used painter's dwarPixmap function and found that a simple rectangle of the basemap scene and the pixmap did the trick.

    QPainter::drawPixmap(const QRect& ,const QPixmap &)

    JW
    sw developer

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.