[SOLVED]How to add an icon(image) to QImage and update the image
-
Think that; I have a button, it creates a QImage and display it in a QLabel.
@QRgb value;
myImage = new QImage(col, row, QImage::Format_RGB32);for( int i = 0; i < row; i++ )
{
for( int j = 0; j < col; j++ )
{
value = qRgb(myData[i][j].intensity *.3,myData[i][j].intensity *.59,myData[i][j].intensity *.11);
myImage->setPixel(j,i,value);
}
}
imageLabel->setPixmap(QPixmap::fromImage(*myImage));
@
Now I add another button and it must add an icon to the QImage and update the displayed image.
@ QPixmap p("abc.png");
QPixmap pixmap = QPixmap::fromImage(*myImage);
QPainter painter(&pixmap);
painter.drawPixmap(100,100, p);
@
I did like this, the program executes the code but does not display the icon.
How can I fix it? -
You have only painted to the pixmap, but you need to set the pixmap to the label you want to show it on (even if it has been set on it before).
-
You are right, thanks
-
-Please mark the topic as [Solved] by editing the title of the topic from your first post.-
Edit: You already did. Thanks :-)