PDA

View Full Version : using QPixmap to transparent image



sophister
7th July 2010, 08:19
Hi, guys, I want to use QPixmap to translate a PNG picture which is not transparent, into a transparent one. But the following codes does not work, for some compiling errors:



int main(int argc, char *argv[])
{
QApplication a(argc, argv);
if(argc < 2)
{
//
std::cout << "no original picture file !" << std::endl;
return 0;
}

QPixmap pix(QString(argv[1])); //original picture
pix.setMask(pix.createHeuristicMask());
QString toWrite("out.png");
if(argc == 3)
{
toWrite = argv[2];
}
pix.save(toWrite, "PNG");
return a.exec();
}


How can the compiler complain that the pix is non-class type"QPixmap"?

Thanks in advance!

borisbn
7th July 2010, 10:41
Did you included this ?


#include <QPixmap>

sophister
8th July 2010, 13:06
Did you included this ?


#include <QPixmap>


thanks, but uh, I have include the necessary header files in the source file. but still some compiling errors.