Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Solved Replace window rectange with image

    General and Desktop
    2
    10
    1777
    Loading More Posts
    • 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
      EpicLoyd last edited by

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

      1 Reply Last reply Reply Quote 0
      • mrjj
        mrjj Lifetime Qt Champion last edited by

        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 Reply Quote 1
        • E
          EpicLoyd last edited by EpicLoyd

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

          mrjj 1 Reply Last reply Reply Quote 1
          • mrjj
            mrjj Lifetime Qt Champion @EpicLoyd last edited by

            @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 Reply Quote 1
            • E
              EpicLoyd @mrjj last edited by

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

              mrjj 1 Reply Last reply Reply Quote 1
              • mrjj
                mrjj Lifetime Qt Champion @EpicLoyd last edited by 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 1 Reply Last reply Reply Quote 1
                • E
                  EpicLoyd @mrjj last edited by

                  @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 Reply Quote 0
                  • mrjj
                    mrjj Lifetime Qt Champion last edited by

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

                    E 1 Reply Last reply Reply Quote 1
                    • E
                      EpicLoyd @mrjj last edited by

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

                      mrjj 1 Reply Last reply Reply Quote 0
                      • mrjj
                        mrjj Lifetime Qt Champion @EpicLoyd last edited by

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

                        1 Reply Last reply Reply Quote 1
                        • First post
                          Last post