PDA

View Full Version : adding QPixmap to scene



rogerholmes
5th June 2009, 23:37
i have copied from the drap and drop demo :


void printcal::dropEvent(QDropEvent *event)

{
if (event->mimeData()->hasFormat("application/x-dnditemdata")) {
QByteArray itemData = event->mimeData()->data("application/x-dnditemdata");
QDataStream dataStream(&itemData, QIODevice::ReadOnly);



QPixmap pixmap;
QPoint offset;
dataStream >> pixmap >> offset;

QLabel *newIcon = new QLabel(this);

newIcon->setPixmap(pixmap);
newIcon->move(event->pos() - offset);
newIcon->show();
newIcon->setAttribute(Qt::WA_DeleteOnClose);



if (event->source() == this) {
event->setDropAction(Qt::MoveAction);
event->accept();




} else {
event->acceptProposedAction();
}
} else {
event->ignore();
}
}

i see the graphic on the scene in the view but

how do i add the pixmap to the Graphics Scene ? I have tried scene->addPixmap(pixmap) , , addItem, addWidget etc... pls help.

i am doing this so i can print the scene with the graphic .

wysota
6th June 2009, 00:13
You have tried those methods and...?

rogerholmes
6th June 2009, 03:44
You have tried those methods and...?

...and the graphic does not get added to the scene. its a calendar app that shows information from a data base added by scene->addText("bla bla") , i see all text info that is added but i cant seem to get the pixmap to be added to the scene. i am sure it is something simple but i havent figured it out.

aamer4yu
6th June 2009, 05:45
Where are you getting the pixmap from ? Make sure it is set properly in mime data.

Secondly what format is the pixmap ? (png,jpg, etc) may be ur Qt was not compiled for them. Also check if you can display that pixmap on a simple QLabel instead of scene