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. Replace window rectange with image
QtWS25 Last Chance

Replace window rectange with image

Scheduled Pinned Locked Moved Solved General and Desktop
10 Posts 2 Posters 2.2k Views
  • 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
    #1

    How to replace window rectangle with some png image ( QMainWindow class ) using stylesheets?

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      hi and welcome
      please see this
      http://stackoverflow.com/questions/19939938/qt-creator-how-do-i-add-a-background-image-to-the-qmainwindow

      1 Reply Last reply
      1
      • E Offline
        E Offline
        EpicLoyd
        wrote on last edited by EpicLoyd
        #3

        many thanks :) but rectangle is still exist http://prntscr.com/9c3x8t and i have... black background

        mrjjM 1 Reply Last reply
        1
        • E EpicLoyd

          many thanks :) but rectangle is still exist http://prntscr.com/9c3x8t and i have... black background

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

          @EpicLoyd
          A note. the samples uses images that are stored in resource file.
          not directly off hard disk.

          the last sample loads it from file

           QPixmap bkgnd("/home/user/Pictures/background.png"); // from file if windows it would be c:/blabla/x.png
           bkgnd = bkgnd.scaled(this->size(), Qt::IgnoreAspectRatio);
            QPalette palette;
            palette.setBrush(QPalette::Background, bkgnd);
           this->setPalette(palette);
          
          E 1 Reply Last reply
          1
          • mrjjM mrjj

            @EpicLoyd
            A note. the samples uses images that are stored in resource file.
            not directly off hard disk.

            the last sample loads it from file

             QPixmap bkgnd("/home/user/Pictures/background.png"); // from file if windows it would be c:/blabla/x.png
             bkgnd = bkgnd.scaled(this->size(), Qt::IgnoreAspectRatio);
              QPalette palette;
              palette.setBrush(QPalette::Background, bkgnd);
             this->setPalette(palette);
            
            E Offline
            E Offline
            EpicLoyd
            wrote on last edited by
            #5

            @mrjj yes of course but... i want to escape window rectangle ( with exit etc buttons)

            mrjjM 1 Reply Last reply
            1
            • E EpicLoyd

              @mrjj yes of course but... i want to escape window rectangle ( with exit etc buttons)

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

              @EpicLoyd
              you mean you want to have a window with no frame and buttons ?
              you can try
              setWindowFlags(Qt::FramelessWindowHint);
              in the constructor of the window.

              ahh just saw the other post.
              look at this
              http://www.codeprogress.com/cpp/libraries/qt/showQtExample.php?index=145&key=QMainWindowPartialTransparent

              make sure the PNG do have transparent areas.

              E 1 Reply Last reply
              1
              • mrjjM mrjj

                @EpicLoyd
                you mean you want to have a window with no frame and buttons ?
                you can try
                setWindowFlags(Qt::FramelessWindowHint);
                in the constructor of the window.

                ahh just saw the other post.
                look at this
                http://www.codeprogress.com/cpp/libraries/qt/showQtExample.php?index=145&key=QMainWindowPartialTransparent

                make sure the PNG do have transparent areas.

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

                @mrjj said:

                @EpicLoyd
                you mean you want to have a window with no frame and buttons ?
                you can try
                setWindowFlags(Qt::FramelessWindowHint);
                in the constructor of the window.

                ahh just saw the other post.
                look at this
                http://www.codeprogress.com/cpp/libraries/qt/showQtExample.php?index=145&key=QMainWindowPartialTransparent

                make sure the PNG do have transparent areas.

                ha, found it too, helped a half: http://prntscr.com/9c4gh4

                1 Reply Last reply
                0
                • mrjjM Offline
                  mrjjM Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  Super.
                  So you might need to add a button to close it :)

                  E 1 Reply Last reply
                  1
                  • mrjjM mrjj

                    Super.
                    So you might need to add a button to close it :)

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

                    @mrjj awwww, i don't think that this is super :( , i've expecting something like this http://prntscr.com/9c4hui

                    mrjjM 1 Reply Last reply
                    0
                    • E EpicLoyd

                      @mrjj awwww, i don't think that this is super :( , i've expecting something like this http://prntscr.com/9c4hui

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

                      @EpicLoyd
                      ok. maybe scale it in photoshop ?
                      Normally it works pretty ok.

                      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