loading QPixmap doesn't work
Code:
MainPlayerBoard
::MainPlayerBoard(QString naam,
short count,
QWidget *parent
): ui(new Ui::MainPlayerBoard)
{
ui->setupUi(this);
eerste.load(":/image.gif");
ui->tile1->pixmap();
ui
->tile1
->setPixmap
(QPixmap::fromImage(eerste
));
ui->tile1->show();
MainPlayerBoard::setWindowTitle(naam);
m_count = count;
}
I first tried to load the pictures from a QVector<QPixmap*> which didn't work.
Then I tried to load them from a QPixmap, didn't work either...
after a while I tried this...
But the problem remains, the QPixmap on my screen does not show up...
Please help me out
Re: loading QPixmap doesn't work
What is 'tile1'? I assume it should be QLabel in you UI. The following code is enough to show pixmap:
Code:
ui
->pixmapLabel
->setPixmap
(QPixmap::fromImage(QImage(":/image.jpg")));
Re: loading QPixmap doesn't work
Quote:
Originally Posted by
dieter
Code:
MainPlayerBoard
::MainPlayerBoard(QString naam,
short count,
QWidget *parent
): ui(new Ui::MainPlayerBoard)
{
ui->setupUi(this);
eerste.load(":/image.gif");
ui->tile1->pixmap();
ui
->tile1
->setPixmap
(QPixmap::fromImage(eerste
));
ui->tile1->show();
MainPlayerBoard::setWindowTitle(naam);
m_count = count;
}
Line 7: Have you checked the return value from QImage::load()? Do you have a GIF image format plugin built and/or deployed?
Line 8 is pointless: I don't know what you are trying to achieve here, but you ignore the return value anyway.
Line 10 is pointless: The label (I assume tile1 is a label) will be shown by default when its parent is shown.
You should be able to construct a QPixmap directly from a GIF or PNG file without an intermediate QImage.