akasi
23rd September 2008, 12:02
Hi! I am trying to display image on the label:
Creating the image:
static const QRgb s_rgnColors[256] =
{
(unsigned int)0x000000,
(unsigned int)0xFF0000,
(unsigned int)0x00FF00,
(unsigned int)0xFFFF00,
(unsigned int)0x0000FF,
(unsigned int)0xFF00FF,
(unsigned int)0x00FFFF,
(unsigned int)0xFFFFFF,
// TODO: think about other colors
(unsigned int)0x000000
};
QImage *m_imageFloor = new QImage(nWidth, nHeight, QImage::Format_Indexed8);
m_imageFloor->setColorTable(QVector<QRgb>::fromStdVector(
std::vector<QRgb>(s_rgnColors, s_rgnColors + _countof(s_rgnColors)))
);
m_imageFloor->fill(7);
and showing it on the label
m_labelFloorPlan = new QLabel();
m_labelFloorPlan->setSizePolicy(QSizePolicy::Expanding,
QSizePolicy::Expanding);
m_labelFloorPlan->setAlignment(Qt::AlignCenter);
m_labelFloorPlan->setMinimumSize(400, 400);
m_labelFloorPlan->setPixmap(QPixmap::fromImage(*m_imageFloor, Qt::AutoColor));
setCentralWidget(m_labelFloorPlan);
But the image does not appear :confused:
What am I doing wrong??
Thank you.
Creating the image:
static const QRgb s_rgnColors[256] =
{
(unsigned int)0x000000,
(unsigned int)0xFF0000,
(unsigned int)0x00FF00,
(unsigned int)0xFFFF00,
(unsigned int)0x0000FF,
(unsigned int)0xFF00FF,
(unsigned int)0x00FFFF,
(unsigned int)0xFFFFFF,
// TODO: think about other colors
(unsigned int)0x000000
};
QImage *m_imageFloor = new QImage(nWidth, nHeight, QImage::Format_Indexed8);
m_imageFloor->setColorTable(QVector<QRgb>::fromStdVector(
std::vector<QRgb>(s_rgnColors, s_rgnColors + _countof(s_rgnColors)))
);
m_imageFloor->fill(7);
and showing it on the label
m_labelFloorPlan = new QLabel();
m_labelFloorPlan->setSizePolicy(QSizePolicy::Expanding,
QSizePolicy::Expanding);
m_labelFloorPlan->setAlignment(Qt::AlignCenter);
m_labelFloorPlan->setMinimumSize(400, 400);
m_labelFloorPlan->setPixmap(QPixmap::fromImage(*m_imageFloor, Qt::AutoColor));
setCentralWidget(m_labelFloorPlan);
But the image does not appear :confused:
What am I doing wrong??
Thank you.