Results 1 to 3 of 3

Thread: using QPixmap to transparent image

  1. #1
    Join Date
    Apr 2009
    Location
    China
    Posts
    127
    Thanks
    30
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question using QPixmap to transparent image

    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:

    Qt Code:
    1. int main(int argc, char *argv[])
    2. {
    3. QApplication a(argc, argv);
    4. if(argc < 2)
    5. {
    6. //
    7. std::cout << "no original picture file !" << std::endl;
    8. return 0;
    9. }
    10.  
    11. QPixmap pix(QString(argv[1])); //original picture
    12. pix.setMask(pix.createHeuristicMask());
    13. QString toWrite("out.png");
    14. if(argc == 3)
    15. {
    16. toWrite = argv[2];
    17. }
    18. pix.save(toWrite, "PNG");
    19. return a.exec();
    20. }
    To copy to clipboard, switch view to plain text mode 

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

    Thanks in advance!

  2. #2
    Join Date
    Apr 2010
    Location
    Rostov-na-Donu, Russia
    Posts
    153
    Thanks
    2
    Thanked 26 Times in 23 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: using QPixmap to transparent image

    Did you included this ?
    Qt Code:
    1. #include <QPixmap>
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Apr 2009
    Location
    China
    Posts
    127
    Thanks
    30
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: using QPixmap to transparent image

    Quote Originally Posted by borisbn View Post
    Did you included this ?
    Qt Code:
    1. #include <QPixmap>
    To copy to clipboard, switch view to plain text mode 
    thanks, but uh, I have include the necessary header files in the source file. but still some compiling errors.

Similar Threads

  1. Converting to transparent Image
    By navi1084 in forum Qt Programming
    Replies: 5
    Last Post: 28th August 2009, 13:25
  2. Create Transparent PNG Image
    By hvitual in forum Qt Programming
    Replies: 1
    Last Post: 2nd August 2009, 14:35
  3. Drawing QIconSet-s on a transparent QPixmap ?
    By ultr in forum Qt Programming
    Replies: 2
    Last Post: 12th March 2009, 14:10
  4. QPixmap(image) to transparent HBITMAP
    By ascii in forum Qt Programming
    Replies: 7
    Last Post: 2nd March 2009, 09:03
  5. create QPixmap semi-transparent
    By jamd in forum Qt Programming
    Replies: 2
    Last Post: 23rd June 2006, 08:08

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.