Results 1 to 2 of 2

Thread: QGraphicsView\Scene drawBackground bitmap as geomap

  1. #1
    Join Date
    Oct 2010
    Posts
    7
    Qt products
    Qt4
    Platforms
    Windows

    Default QGraphicsView\Scene drawBackground bitmap as geomap

    have some code..

    declaration
    QPixmap map;
    QGraphicsView

    in MainWin construct
    view->setDragMode(QGraphicsView::ScrollHandDrag);
    view->centerOn(0,0);// after it tha map is drawing to 0,0 on left,top on the scene

    but if move the scrolls then map is spoiled and repaint to left,top of visible area of QGraphicsView

    I need to paint map to 0,0 always.

    Qt Code:
    1. NetView::NetView(QGraphicsScene *scene, QWidget *parent)
    2. : QGraphicsView(scene, parent)
    3. {
    4. QString name = "C:/MAP1.bmp";
    5. map.load(name);
    6. }
    7.  
    8. void NetView::drawBackground(QPainter *painter, const QRectF &rect)
    9. {
    10. painter->drawPixmap(rect.left(),rect.top(),map);
    11. }
    To copy to clipboard, switch view to plain text mode 
    if I override Scene::drawBackground effect is the same.

    I made painting map as brush:
    view->setBackgroundBrush(QPixmap("C:/RUSMAP1.bmp"));
    it's cool and working great but map is tiled I need one tile in the left,top corner
    Last edited by pethead; 29th October 2010 at 08:22.

  2. #2
    Join Date
    Oct 2010
    Posts
    7
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QGraphicsView\Scene drawBackground bitmap as geomap

    found solutuon:

    void cene::drawBackground(QPainter *painter, const QRectF &rect)
    {
    int w=img.width();
    int h=img.height();
    QRectF r;
    r.setRect(0,0,w,h);

    painter->drawImage(r,img);
    }

Similar Threads

  1. QGraphicsView/Scene to png image
    By nileshsince1980 in forum Qt Programming
    Replies: 3
    Last Post: 21st May 2010, 14:27
  2. can I get another QGraphicsView's scene?
    By sincnarf in forum Qt Programming
    Replies: 1
    Last Post: 28th June 2007, 22:41
  3. How to use QGraphicsView and Scene right ...
    By Mike in forum Qt Programming
    Replies: 6
    Last Post: 22nd January 2007, 09:51
  4. Possible QGraphicsView/Scene bug
    By Corran in forum Qt Programming
    Replies: 1
    Last Post: 30th December 2006, 02:47
  5. QPainter and QGraphicsView drawBackground() override
    By forrestfsu in forum Qt Programming
    Replies: 4
    Last Post: 5th December 2006, 16:52

Tags for this Thread

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.