Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QPixmap save problem
Qt 6.11 is out! See what's new in the release blog

QPixmap save problem

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 1.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Gianluca86G Offline
    Gianluca86G Offline
    Gianluca86
    wrote on last edited by
    #1

    Hi everyone,
    I'm trying to save a simple QPixmap, but the result is not what I want.
    This is my code:

    QPixmap CreatePixmap(200,200);
    QPainter CreatePainter(&CreatePixmap);
    CreatePainter.setBackground(Qt::white);
    CreatePainter.drawText(QPointF(10,10),"Hello world!!");
    
    QFile SaveFile("AATest.bmp");
    if(SaveFile.open(QIODevice::WriteOnly))
    {
        CreatePixmap.save(&SaveFile, "BMP",100);
    }
    SaveFile.close();
    

    This is the image.
    Image link

    What did I do wrong? I forgot something?

    thanks

    1 Reply Last reply
    0
    • p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      @Gianluca86 You should fillRect with white color instead.

      157

      1 Reply Last reply
      3
      • Gianluca86G Offline
        Gianluca86G Offline
        Gianluca86
        wrote on last edited by
        #3

        Thanks a lot, now is perfect.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved