Results 1 to 4 of 4

Thread: QGraphicsView QGraphicsScene QPixmap - pixmap positioning

  1. #1
    Join Date
    Mar 2010
    Posts
    86
    Thanks
    11
    Thanked 7 Times in 4 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default QGraphicsView QGraphicsScene QPixmap - pixmap positioning

    I am using the QGraphicsView/QGraphicsScene with QPixmaps. The first pixmap is my background (but is still just a pixmap) and then I have subsequent pixmaps (transparent .gifs) that I want to place inside the graphics view but the starting position (left/top) of the second pixmap needs to be offset so many pixels to the left and down. I get the pixmaps all drawing at the 0,0 of the entire graphicsview. I scoured the Qt assistant for some QgraphicsView & QPixmap classes and I'm damned if there is a class funtion that does this. I can just go into photoshop and add more left and top to the transparent .gif and therefore 'put' it where I want to. But this seems like a cheap fix. I thought that the items would be able to be moveable inside the graphicsView.

    this is how I'm drawing it....

    scene is a public QGraphicsScene in the mainwindow.h


    ui->graphicsView->setSceneRect(0,0,300, 450);
    scene.setSceneRect(0,0,300,450);

    QPixmap g(":/pics/gallow.jpg");
    QPixmap e(":/pics/photoCopyFullBody.gif");

    scene.addPixmap(g);
    scene.addPixmap(e);

    ui->graphicsView->setScene(& scene);

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: QGraphicsView QGraphicsScene QPixmap - pixmap positioning

    Please read the docs about Qt's graphics view. For starting a small pice of code:
    Qt Code:
    1. QGraphicsPixmapItem* item = scene.addPixmap(g);
    2. item->setPos(15, -30);
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Mar 2010
    Posts
    86
    Thanks
    11
    Thanked 7 Times in 4 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QGraphicsView QGraphicsScene QPixmap - pixmap positioning

    Thanks I got it up and running and want to thank you for the help. I thought that the QGraphicsPixmapItem was a whole different scheme than my QGraphicsScene in the QGraphicsView. I have an executable zip on my website server if you'd like to see what I got done... Not sure of the protocol of whipping out a link to a .zip file on here....(it has all the .dll's necessary to run. 12mb) is there a way to submit a program to QtCentre?

  4. #4
    Join Date
    Mar 2010
    Posts
    86
    Thanks
    11
    Thanked 7 Times in 4 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QGraphicsView QGraphicsScene QPixmap - pixmap positioning

    I put an example pic in my Album....

Similar Threads

  1. QGraphicsScene item positioning
    By been_1990 in forum Qt Programming
    Replies: 7
    Last Post: 28th July 2009, 12:11
  2. problem in positioning item in QGraphicsScene()
    By wagmare in forum Qt Programming
    Replies: 4
    Last Post: 8th May 2009, 06:41
  3. Position in a QPixMap created from a QGraphicsScene
    By stevel in forum Qt Programming
    Replies: 8
    Last Post: 8th April 2009, 22:39
  4. AddLine over QGraphicsscene Pixmap
    By Qt Coder in forum Qt Programming
    Replies: 3
    Last Post: 25th March 2009, 08:12
  5. QPixmap display on QGraphicsScene
    By febil in forum Qt Programming
    Replies: 2
    Last Post: 26th February 2009, 09:27

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.