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. Avoiding background image of Main window in child widgets
Forum Update on Monday, May 27th 2025

Avoiding background image of Main window in child widgets

Scheduled Pinned Locked Moved Solved General and Desktop
10 Posts 3 Posters 2.1k 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.
  • VineelaV Offline
    VineelaV Offline
    Vineela
    wrote on last edited by Vineela
    #1

    I've set border image for main window and added frame to the main window, but the image of main window is repeated to the frame too. To this i gave background:transparent to the frame even though not working.
    Therefore my need is to fit image to main window where the image shud not repeat in any other fileds.

    image.png (image url)

    sankarapandiyanS 1 Reply Last reply
    0
    • VineelaV Vineela

      I've set border image for main window and added frame to the main window, but the image of main window is repeated to the frame too. To this i gave background:transparent to the frame even though not working.
      Therefore my need is to fit image to main window where the image shud not repeat in any other fileds.

      image.png (image url)

      sankarapandiyanS Offline
      sankarapandiyanS Offline
      sankarapandiyan
      wrote on last edited by
      #2

      @Vineela .. You want to transparent the background image !

      VineelaV 1 Reply Last reply
      0
      • sankarapandiyanS sankarapandiyan

        @Vineela .. You want to transparent the background image !

        VineelaV Offline
        VineelaV Offline
        Vineela
        wrote on last edited by
        #3

        @sankarapandiyan nope not working i did that too.

        sankarapandiyanS 1 Reply Last reply
        0
        • VineelaV Vineela

          @sankarapandiyan nope not working i did that too.

          sankarapandiyanS Offline
          sankarapandiyanS Offline
          sankarapandiyan
          wrote on last edited by sankarapandiyan
          #4

          @Vineela I think here the frame is in transparent . So, You first need to change the frame nature and then fix the frame in Mainwindow.
          May be try this , I dont know this one is work or not . but try this method

          frame->setAttribute(Qt::WA_NoSystemBackground);
          frame->setAttribute(Qt::WA_OpaquePaintEvent);
          frame->setStyleSheet("background-color: transparent");
          frame->setStyleSheet("opacity: 0");
          
          VineelaV 2 Replies Last reply
          0
          • sankarapandiyanS sankarapandiyan

            @Vineela I think here the frame is in transparent . So, You first need to change the frame nature and then fix the frame in Mainwindow.
            May be try this , I dont know this one is work or not . but try this method

            frame->setAttribute(Qt::WA_NoSystemBackground);
            frame->setAttribute(Qt::WA_OpaquePaintEvent);
            frame->setStyleSheet("background-color: transparent");
            frame->setStyleSheet("opacity: 0");
            
            VineelaV Offline
            VineelaV Offline
            Vineela
            wrote on last edited by
            #5
            This post is deleted!
            1 Reply Last reply
            0
            • sankarapandiyanS sankarapandiyan

              @Vineela I think here the frame is in transparent . So, You first need to change the frame nature and then fix the frame in Mainwindow.
              May be try this , I dont know this one is work or not . but try this method

              frame->setAttribute(Qt::WA_NoSystemBackground);
              frame->setAttribute(Qt::WA_OpaquePaintEvent);
              frame->setStyleSheet("background-color: transparent");
              frame->setStyleSheet("opacity: 0");
              
              VineelaV Offline
              VineelaV Offline
              Vineela
              wrote on last edited by
              #6

              @sankarapandiyan nope this didn't work too

              sankarapandiyanS 1 Reply Last reply
              0
              • VineelaV Vineela

                @sankarapandiyan nope this didn't work too

                sankarapandiyanS Offline
                sankarapandiyanS Offline
                sankarapandiyan
                wrote on last edited by sankarapandiyan
                #7

                @Vineela

                click and see the link link text by this , you may get some idea ... The Topic is about overriding background image of child components

                And my point is we can change the setting of the frame (REMOVING BACKGROUND) through the code itself only.

                    QFrame* plbl = new QFrame("foobar");
                    plbl->setGeometry(210, 0, 26, 16);
                    plbl->setAlignment(Qt::AlignRight);
                    plbl->setAlignment(Qt::AlignVCenter);
                    plbl->setWindowFlag(Qt::FramelessWindowHint); // No frame
                    plbl->setAttribute(Qt::WA_NoSystemBackground); // No background
                    plbl->setAttribute(Qt::WA_TranslucentBackground);
                    plbl->show();
                

                Like this we can remove the background colour or we can change the background colour

                VineelaV 1 Reply Last reply
                0
                • sankarapandiyanS sankarapandiyan

                  @Vineela

                  click and see the link link text by this , you may get some idea ... The Topic is about overriding background image of child components

                  And my point is we can change the setting of the frame (REMOVING BACKGROUND) through the code itself only.

                      QFrame* plbl = new QFrame("foobar");
                      plbl->setGeometry(210, 0, 26, 16);
                      plbl->setAlignment(Qt::AlignRight);
                      plbl->setAlignment(Qt::AlignVCenter);
                      plbl->setWindowFlag(Qt::FramelessWindowHint); // No frame
                      plbl->setAttribute(Qt::WA_NoSystemBackground); // No background
                      plbl->setAttribute(Qt::WA_TranslucentBackground);
                      plbl->show();
                  

                  Like this we can remove the background colour or we can change the background colour

                  VineelaV Offline
                  VineelaV Offline
                  Vineela
                  wrote on last edited by
                  #8

                  @sankarapandiyan ahhhhh non helping......

                  1 Reply Last reply
                  1
                  • VRoninV Offline
                    VRoninV Offline
                    VRonin
                    wrote on last edited by VRonin
                    #9

                    Give your central widget an object name (e.g. widget->setObjectName("MyWindow");). This allows you to set the border image in the stylesheet for that specific object without having it cascading (e.g. #MyWindow { border-image: url(:/images/background.png) })

                    "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
                    ~Napoleon Bonaparte

                    On a crusade to banish setIndexWidget() from the holy land of Qt

                    1 Reply Last reply
                    3
                    • VineelaV Offline
                      VineelaV Offline
                      Vineela
                      wrote on last edited by
                      #10

                      Well thank you all, I figured it out that is if i give border-image to main window i should give border-image:transparent to all child widgets . :)

                      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