PDA

View Full Version : QGraphicsView QGraphicsScene QPixmap - pixmap positioning



budda
21st March 2010, 18:53
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);

Lykurg
21st March 2010, 21:27
Please read the docs about Qt's graphics view. For starting a small pice of code:
QGraphicsPixmapItem* item = scene.addPixmap(g);
item->setPos(15, -30);

budda
16th April 2010, 07:41
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?

budda
16th April 2010, 07:56
I put an example pic in my Album....