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 759 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.
  • B Offline
    B Offline
    beautifulcloud
    wrote on 28 Jun 2023, 14:18 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

    J 1 Reply Last reply 28 Jun 2023, 16:26
    0
    • B beautifulcloud
      28 Jun 2023, 17:07

      @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;
      
      
      J Offline
      J Offline
      JonB
      wrote on 28 Jun 2023, 17:31 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.

      B 1 Reply Last reply 28 Jun 2023, 17:48
      2
      • B beautifulcloud
        28 Jun 2023, 14:18

        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

        J Offline
        J Offline
        JonB
        wrote on 28 Jun 2023, 16:26 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?

        B 1 Reply Last reply 28 Jun 2023, 16:46
        0
        • J JonB
          28 Jun 2023, 16:26

          @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?

          B Offline
          B Offline
          beautifulcloud
          wrote on 28 Jun 2023, 16:46 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

          J 1 Reply Last reply 28 Jun 2023, 17:00
          0
          • B beautifulcloud
            28 Jun 2023, 16:46

            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

            J Offline
            J Offline
            JonB
            wrote on 28 Jun 2023, 17:00 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?

            B 1 Reply Last reply 28 Jun 2023, 17:07
            0
            • J JonB
              28 Jun 2023, 17:00

              @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?

              B Offline
              B Offline
              beautifulcloud
              wrote on 28 Jun 2023, 17:07 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;
              
              
              J 1 Reply Last reply 28 Jun 2023, 17:31
              0
              • B beautifulcloud
                28 Jun 2023, 17:07

                @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;
                
                
                J Offline
                J Offline
                JonB
                wrote on 28 Jun 2023, 17:31 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.

                B 1 Reply Last reply 28 Jun 2023, 17:48
                2
                • J JonB
                  28 Jun 2023, 17:31

                  @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.

                  B Offline
                  B Offline
                  beautifulcloud
                  wrote on 28 Jun 2023, 17:48 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
                  • B beautifulcloud has marked this topic as solved on 28 Jun 2023, 17:48

                  2/7

                  28 Jun 2023, 16:26

                  topic:navigator.unread, 5
                  • Login

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