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. QT Designer changing the child's stylesheet from the parent's stylesheet

QT Designer changing the child's stylesheet from the parent's stylesheet

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

    Hello,

    I applied a fairly simple stylesheet to a widget to this apply a border. The labels in the widget are therefore also affected by the border and I would like to add an instruction to be able to remove it but I don't know how to do it and if we can do it without going through source code :
    7bbeb3f3-c8b2-47ed-a609-c059e71979fc-image.png

    Thanks

    JonBJ 1 Reply Last reply
    0
    • beautifulcloudB beautifulcloud

      @JonB The CSS above is the stylesheet of the widget so the parent?
      Then the child label has nothing

      The widget QSS/CSS :

      background-color: #573622;
      border: 3px solid #663d24;
      
      
      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #6

      @beautifulcloud
      My bad, now I understand from your screenshot. I had not seen it was doing anything other than the QLabel.

      Not sure quite how you "cancel" or "override". I would try something other than none to test if that works.

      In order to set only the border of this "parent" widget, and not worry about affecting its children, why not try giving it an objectName of thisWidget and then:

      #thisWidget { border: 3px solid #663d24; }
      

      Then you don't need the QLabel rule for children.

      beautifulcloudB 1 Reply Last reply
      2
      • beautifulcloudB beautifulcloud

        Hello,

        I applied a fairly simple stylesheet to a widget to this apply a border. The labels in the widget are therefore also affected by the border and I would like to add an instruction to be able to remove it but I don't know how to do it and if we can do it without going through source code :
        7bbeb3f3-c8b2-47ed-a609-c059e71979fc-image.png

        Thanks

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by
        #2

        @beautifulcloud said in QT Designer changing the child's stylesheet from the parent's stylesheet:

        I applied a fairly simple stylesheet to a widget to this apply a border.

        Could you show how exactly you did this, what the QSS looks like?

        beautifulcloudB 1 Reply Last reply
        0
        • JonBJ JonB

          @beautifulcloud said in QT Designer changing the child's stylesheet from the parent's stylesheet:

          I applied a fairly simple stylesheet to a widget to this apply a border.

          Could you show how exactly you did this, what the QSS looks like?

          beautifulcloudB Offline
          beautifulcloudB Offline
          beautifulcloud
          wrote on last edited by
          #3

          Hello @JonB ,
          The image above is the CSS of the widget, so the label inside the widget have border too and I would like to remove it
          fee3d997-f7e8-4ad0-8d93-0a2238bf8886-image.png

          Since I have a lot of labels to add I was wondering if it was possible to remove the border of the label by adding a CSS code to the widget without going through the source code

          QLabel {
             border: none;
          }
          
          

          But it doesn't work I guess we are not supposed to do like this

          JonBJ 1 Reply Last reply
          0
          • beautifulcloudB beautifulcloud

            Hello @JonB ,
            The image above is the CSS of the widget, so the label inside the widget have border too and I would like to remove it
            fee3d997-f7e8-4ad0-8d93-0a2238bf8886-image.png

            Since I have a lot of labels to add I was wondering if it was possible to remove the border of the label by adding a CSS code to the widget without going through the source code

            QLabel {
               border: none;
            }
            
            

            But it doesn't work I guess we are not supposed to do like this

            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by JonB
            #4

            @beautifulcloud
            No, I want to see the text of whatever QSS/CSS you added to the parent where you say

            I applied a fairly simple stylesheet to a widget to this apply a border.

            You have shown how you are trying to cancel the children's borders. I would like to see how you set the parent's border?

            beautifulcloudB 1 Reply Last reply
            0
            • JonBJ JonB

              @beautifulcloud
              No, I want to see the text of whatever QSS/CSS you added to the parent where you say

              I applied a fairly simple stylesheet to a widget to this apply a border.

              You have shown how you are trying to cancel the children's borders. I would like to see how you set the parent's border?

              beautifulcloudB Offline
              beautifulcloudB Offline
              beautifulcloud
              wrote on last edited by beautifulcloud
              #5

              @JonB The CSS above is the stylesheet of the widget so the parent?
              Then the child label has nothing

              The widget QSS/CSS :

              background-color: #573622;
              border: 3px solid #663d24;
              
              
              JonBJ 1 Reply Last reply
              0
              • beautifulcloudB beautifulcloud

                @JonB The CSS above is the stylesheet of the widget so the parent?
                Then the child label has nothing

                The widget QSS/CSS :

                background-color: #573622;
                border: 3px solid #663d24;
                
                
                JonBJ Offline
                JonBJ Offline
                JonB
                wrote on last edited by
                #6

                @beautifulcloud
                My bad, now I understand from your screenshot. I had not seen it was doing anything other than the QLabel.

                Not sure quite how you "cancel" or "override". I would try something other than none to test if that works.

                In order to set only the border of this "parent" widget, and not worry about affecting its children, why not try giving it an objectName of thisWidget and then:

                #thisWidget { border: 3px solid #663d24; }
                

                Then you don't need the QLabel rule for children.

                beautifulcloudB 1 Reply Last reply
                2
                • JonBJ JonB

                  @beautifulcloud
                  My bad, now I understand from your screenshot. I had not seen it was doing anything other than the QLabel.

                  Not sure quite how you "cancel" or "override". I would try something other than none to test if that works.

                  In order to set only the border of this "parent" widget, and not worry about affecting its children, why not try giving it an objectName of thisWidget and then:

                  #thisWidget { border: 3px solid #663d24; }
                  

                  Then you don't need the QLabel rule for children.

                  beautifulcloudB Offline
                  beautifulcloudB Offline
                  beautifulcloud
                  wrote on last edited by
                  #7

                  Okay I did this in QT Designer and it worked well :)
                  I didn't understand what syntax was usable

                  Thanks for your help @JonB
                  af160150-654d-4c77-8cf1-c45d9941ae3a-image.png

                  1 Reply Last reply
                  0
                  • beautifulcloudB beautifulcloud has marked this topic as solved on

                  • Login

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