Eneswar
19th April 2011, 15:39
I'm trying to add an image to a widget which is connected to a lib. But for some reason I just can't seem to get the image to show. Or the image is hidden behind the widget, I don't know. I tried this on a new widget with no lib and it's working fine. Any help would be highely appreciated.
I have tried with two different codes:
void CDILedIndicator::paintEvent(QPaintEvent *)
{
QPainter *test = new QPainter(this);
QImage test1;
if(knapp)
test1.load(":/Images/BlueOff");
else
test1.load(":/Images/BlueOn");
test->drawImage(0, 0, test1);
}
and also with:
void CDILedIndicator::paintEvent(QPaintEvent *)
{
QPoint pos(0,0);
drawIcon(m_painter, &pos);
}
void CDILedIndicator::drawIcon(QPainter *painter, QPoint *position)
{
QImage OnIcon(":/Images/BlueOn");
QImage OffIcon(":/Images/BlueOff");
ledValue ? painter->drawImage(*position, OnIcon) :
painter->drawImage(*position, OffIcon);
}
I have tried with two different codes:
void CDILedIndicator::paintEvent(QPaintEvent *)
{
QPainter *test = new QPainter(this);
QImage test1;
if(knapp)
test1.load(":/Images/BlueOff");
else
test1.load(":/Images/BlueOn");
test->drawImage(0, 0, test1);
}
and also with:
void CDILedIndicator::paintEvent(QPaintEvent *)
{
QPoint pos(0,0);
drawIcon(m_painter, &pos);
}
void CDILedIndicator::drawIcon(QPainter *painter, QPoint *position)
{
QImage OnIcon(":/Images/BlueOn");
QImage OffIcon(":/Images/BlueOff");
ledValue ? painter->drawImage(*position, OnIcon) :
painter->drawImage(*position, OffIcon);
}