Results 1 to 2 of 2

Thread: QGraphicsScene QPixmap background

  1. #1
    Join Date
    Jul 2010
    Qt products
    MacOS X Unix/X11

    Question QGraphicsScene QPixmap background

    Hi All,

    I am trying to load a pixmap as a background for a QGraphics scene using this code:

    QString backGround = ":/Scope.png";

    My scene size is 500 x 500. When I set the scene with 0,0 at topleft and 500,500 height width, the background image displays properly.
    ( scopeScene->setSceneRect(0,0,500,500); )

    But I need to offset the scene coords using "scopeScene->setSceneRect(-250,-250,500,500); " so that it extends from -250 to 250 instead of 0 - 500.

    When I do that, the background image is offset wrong and looks like each quadrant gets a different piece of the image, instead of one continuous image.

    How do I offset the screneRect and still load the background image centered in my view?

    Thank you in advance,


  2. #2
    Join Date
    Mar 2009
    Brisbane, Australia
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Unix/X11 Windows
    Wiki edits

    Default Re: QGraphicsScene QPixmap background

    You can customise how the background brush is drawn in QGraphicsScene::drawBackground((). You probably want the QGraphicsView version of these functions, or a different viewport widget, if you want to keep the image in the view.

Similar Threads

  1. QPixmap as background of QWidget
    By Alan_K in forum Qt Programming
    Replies: 2
    Last Post: 17th March 2013, 16:03
  2. QPixmap's background
    By Dopt in forum Qt Programming
    Replies: 3
    Last Post: 31st May 2012, 16:20
  3. Rendering QGraphicsScene to QPixmap to save
    By Rooster in forum Qt Programming
    Replies: 1
    Last Post: 9th April 2009, 06:24
  4. Position in a QPixMap created from a QGraphicsScene
    By stevel in forum Qt Programming
    Replies: 8
    Last Post: 8th April 2009, 23:39
  5. QPixmap display on QGraphicsScene
    By febil in forum Qt Programming
    Replies: 2
    Last Post: 26th February 2009, 10:27

Tags for this Thread


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.