PDA

View Full Version : QGraphicsObject doesn't display QPixmap



uLtRaLoVeR
28th August 2013, 12:27
I'm developing a very simple application on win7 and running on win8.
When I run on win7 it shows the pixmap drawn by my QGraphicsObject subclass. However when I copy the exe and dll's to the my tablet it doesn't show the pixmap but everything else is the same.

Another problem is when I quit the application it says unexpectedly closed.

Here are the related parts



myImage::myImage(QGraphicsObject *parent) :
QGraphicsObject(parent)
{
pxm = new QPixmap("://images/flower.jpg");
setScale(0.5);
}

QRectF myImage::boundingRect() const
{
QRectF rect(0,0,pxm->width(),pxm->height());
return rect;
}

void myImage::paint(QPainter *painter, const QStyleOptionGraphicsItem */*option*/, QWidget */*widget*/)
{
painter->drawPixmap(0,0,pxm->width(),pxm->height(),*pxm);
}






Here is the main function



int main(int argc, char *argv[])
{
QApplication app(argc, argv);

QGraphicsScene scene;

myImage img;
scene.addItem(&img);

QGraphicsView view(&scene);

QWidget window;
window.setFixedHeight(400);
window.setFixedWidth(500);
window.setSizePolicy(QSizePolicy::Fixed,QSizePolic y::Fixed);


QPushButton button("Quit");
QObject::connect(&button,SIGNAL(clicked()),&app,SLOT(quit()));
QVBoxLayout layout;
layout.addWidget(&view);
layout.addWidget(&button);
window.setLayout(&layout);
window.show();
return app.exec();
}

wysota
28th August 2013, 12:53
http://www.qtcentre.org/faq.php?faq=qt_images#faq_qt_missing_images