Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
How to set the background of Qimage to transparent?
i am new to Qt programming. i have created the Qimage object by providing image[.png] file.
i am using qt 4.8
please help me to set transparent background of image. currently it shows black background.
you can try to convert the QImage:
image = image.convertToFormat(QImage::Format_ARGB32);
Assuming the PNG file really has a alpha channel set.
i checked the format and it has Format_ARGB32. also i have checked the alpha set by using hasAlphaChannel () Api and it returns true.
one more thing i forgot to tell u that i am generating custom Qcursor from the image.
so why don't you just use QPixmap directly?
widget->setCursor( QCursor( QPixmap("image.png") ) );
I did what you say but did not get transparent background for the custom curosr
actually i am converting my application from 3.0 to 4.8. the code for custom cursor is already implemented. it works fine it qt 3.0. cursor has transparent background when it works in qt 3.0. but when i test same code in qt 4.8 it shows black background.
Ex code snippet.
setPixel according to height and width of Qimage object.
is anything wrong here. please help me i have tried several combination for this
Please anybody knows this issue ..... i am stuck with this
can you post the cursor image (png file)?
IamSumit last edited by
Try this combination...[Qt 4.8]
If You have transparent cursor image then it would be good ,other wise make cursor png to transparent.
i had tried that one but no result. actually a black box appears around the custom cursor. the image that is used in custom cursor is not transparent but with the code snippet that i had paste earlier works with not transparent image in qt 3.0. i just port my application to qt 4.8 and the problem starts here.
please help me to resolve this issue.
I just want to set transparent background of cursor. currently it shows black background around the cursor