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||QMainWindow problem
Qt 6.11 is out! See what's new in the release blog

QPixmap||QMainWindow problem

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 2 Posters 2.7k 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.
  • E Offline
    E Offline
    EpicLoyd
    wrote on last edited by EpicLoyd
    #1

    I'm trying to set background to my window. i have an png image with alpha channel. When i'm scaling image to fit in size of my window only mask of this image is scaled, image - not.
    link text --- image

    MainWindow::MainWindow(QApplication *app,QWidget *parent) : QMainWindow(parent),ui(new Ui::MainWindow)
    {
    	this->app = app;
        ui->setupUi(this);
    
        setWindowFlags( Qt::FramelessWindowHint );
    
        QPixmap bkgnd(":/launcher_body.png");
    
        qDebug() << bkgnd.size();
       bkgnd = bkgnd.scaled(this->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
        qDebug() << bkgnd.size();
    
    
        QPalette palette;
        palette.setBrush(QPalette::Background, bkgnd);
        this->setPalette(palette);
        this->setMask(bkgnd.mask());
    }
    ```)
    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      Its strange
      I tried your code here and it does scale the actual image to the size of
      the mainwindow.

      http://postimg.org/image/4nfa4zlil/

      E 1 Reply Last reply
      1
      • mrjjM mrjj

        Hi
        Its strange
        I tried your code here and it does scale the actual image to the size of
        the mainwindow.

        http://postimg.org/image/4nfa4zlil/

        E Offline
        E Offline
        EpicLoyd
        wrote on last edited by
        #3

        @mrjj could it be related to image itself? ( e.g: wrong parameters to save image?)

        mrjjM 1 Reply Last reply
        0
        • E EpicLoyd

          @mrjj could it be related to image itself? ( e.g: wrong parameters to save image?)

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @EpicLoyd
          i wondered that too but png is png.
          but fast to test
          https://www.dropbox.com/s/xflsnfngw8wjlx0/Untitled-1.png?dl=0
          as mine did

          The code shown is the full version yes?
          U do nothing else with the image?

          E 1 Reply Last reply
          0
          • mrjjM mrjj

            @EpicLoyd
            i wondered that too but png is png.
            but fast to test
            https://www.dropbox.com/s/xflsnfngw8wjlx0/Untitled-1.png?dl=0
            as mine did

            The code shown is the full version yes?
            U do nothing else with the image?

            E Offline
            E Offline
            EpicLoyd
            wrote on last edited by EpicLoyd
            #5

            @mrjj umm http://prntscr.com/9j0tbe probably this is mask. Actual image aligned and we can't see it
            http://prntscr.com/9j0tm1
            no, i did nothing
            uh oh
            "libpng warning: iCCP: known incorrect sRGB profile"

            mrjjM 1 Reply Last reply
            0
            • E EpicLoyd

              @mrjj umm http://prntscr.com/9j0tbe probably this is mask. Actual image aligned and we can't see it
              http://prntscr.com/9j0tm1
              no, i did nothing
              uh oh
              "libpng warning: iCCP: known incorrect sRGB profile"

              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by mrjj
              #6

              @EpicLoyd
              Ok it does different on your platform.
              it should be red.
              Im on win 7.
              what is your platform?
              update:
              you use another theme than me.
              I wonder if picture is really shown ?
              It seems just to be mask.

              -"libpng warning: iCCP: known incorrect sRGB profile"
              yeah, it seems the png plugin dont like photoshops normal color profile.
              Its from within libpng. still shows correctly.

              E 1 Reply Last reply
              0
              • mrjjM mrjj

                @EpicLoyd
                Ok it does different on your platform.
                it should be red.
                Im on win 7.
                what is your platform?
                update:
                you use another theme than me.
                I wonder if picture is really shown ?
                It seems just to be mask.

                -"libpng warning: iCCP: known incorrect sRGB profile"
                yeah, it seems the png plugin dont like photoshops normal color profile.
                Its from within libpng. still shows correctly.

                E Offline
                E Offline
                EpicLoyd
                wrote on last edited by
                #7

                @mrjj i've fixed my issue by using another way of paiting - override paint event

                1 Reply Last reply
                1

                • Login

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