Results 1 to 3 of 3

Thread: QGraphicsScene background

  1. #1
    Join Date
    Apr 2009
    Location
    China
    Posts
    15
    Qt products
    Qt4
    Platforms
    Unix/X11

    Smile QGraphicsScene background

    hi all:
    I set a file(*.jpg) at the background of QGraphicsScene, but the picture as tiling on the scene , I want to tensilie the picture on the scene, what to do it?
    thanks a lot.
    the code :
    Qt Code:
    1. int screen_width = QApplication::desktop()->width();
    2. int screen_height = QApplication::desktop()->height();
    3.  
    4. scene = new QGraphicsScene(0,0,screen_width,screen_height);
    5. airview = new QGraphicsView();
    6. setCentralWidget(airview);
    7. QPixmap pim("./images/airport.jpg");
    8. scene->setBackgroundBrush(pim.scaled(screen_width,screen_height,Qt::IgnoreAspectRatio,Qt::SmoothTransformation));
    9. airview->setScene(scene);
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QGraphicsScene background

    You can try scaling the pic to the sceneRect.
    Other way round is to inherit the scene, and draw the background pixmap yourself. Have a look at QGraphicsScene::drawBackground

  3. #3
    Join Date
    Apr 2009
    Location
    China
    Posts
    15
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QGraphicsScene background

    the class QGraphicsScene draw background as tiles ,I don't know how to rewrite the drawBackground()
    the pixmap in the center of the scene

Similar Threads

  1. Replies: 0
    Last Post: 6th April 2009, 01:20
  2. Replies: 0
    Last Post: 5th March 2009, 06:54
  3. How to redraw QGraphicsScene background in running
    By wisconxing in forum Qt Programming
    Replies: 3
    Last Post: 17th November 2008, 13:10
  4. OpenGL texture on QGraphicsScene background
    By Ovnan in forum Qt Programming
    Replies: 5
    Last Post: 11th July 2008, 10:39
  5. Moving the QGraphicsScene background content
    By maverick_pol in forum Qt Programming
    Replies: 5
    Last Post: 16th May 2008, 07:37

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.