×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Nokia Developer Champion
    Join Date
    Feb 2009
    Location
    India
    Posts
    813

    How to position QGraphicsView?

    Hi

    I am trying to display a png image. The code I used is shown below. The problem is that I am unable to set the position of image to be displayed.
    By default, it is getting displayed in the L.H.S.


    Code:
    int main(int argc, char *argv[])
    {
       QApplication a(argc, argv);
       QGraphicsScene scene;
       QGraphicsView view(&scene);
       QGraphicsPixmapItem item(QPixmap("c:\\Sunset.jpg"));
       scene.addItem(&item);
       view.show();
       return a.exec();
    }
    I tried using Scale() and SetAlignment(). But no use.

  2. #2
    Nokia Developer Champion
    Join Date
    Feb 2009
    Location
    India
    Posts
    813

    Re: How to position QGraphicsView?

    Got it solved by using QGraphicsScene::setSceneRect(). Earlier I was trying to use QGraphicsView's functions to place it properly.

  3. #3
    Nokia Developer Moderator
    Join Date
    Oct 2009
    Posts
    4,326

    Re: How to position QGraphicsView?

    It should be done with QGraphicsPixmapItem::setOffset().

Similar Threads

  1. QGraphicsView
    By vlad2048 in forum Qt
    Replies: 6
    Last Post: 2010-11-13, 23:19
  2. QgraphicsView after scale.
    By Estel in forum Qt
    Replies: 2
    Last Post: 2010-04-20, 12:31
  3. scrolling in QGraphicsView
    By rkurvakat in forum Nokia N9
    Replies: 5
    Last Post: 2010-04-08, 16:14
  4. Fingerscrolling in QGraphicsView framework
    By kleimola in forum Nokia N9
    Replies: 14
    Last Post: 2010-02-13, 11:59

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •