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. How to apply qss to a custom class

How to apply qss to a custom class

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 4 Posters 1.4k 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.
  • I Offline
    I Offline
    IknowQT
    wrote on 4 Mar 2022, 04:07 last edited by
    #1

    We have created a usrCntrListWidget class that inherits from Qlistwidget.
    I declared in qss to apply qss. The declaration is:

    usrCntrListWidget
    {
    border: 4px solid #B8BCBF;
    }
    

    I declared this, but the style is not applied.

    But

    QListWidget
    {
    border: 4px solid #B8BCBF;
    }
    

    If declared as , the style is applied.

    P J 2 Replies Last reply 4 Mar 2022, 16:37
    0
    • I IknowQT
      4 Mar 2022, 04:07

      We have created a usrCntrListWidget class that inherits from Qlistwidget.
      I declared in qss to apply qss. The declaration is:

      usrCntrListWidget
      {
      border: 4px solid #B8BCBF;
      }
      

      I declared this, but the style is not applied.

      But

      QListWidget
      {
      border: 4px solid #B8BCBF;
      }
      

      If declared as , the style is applied.

      P Offline
      P Offline
      Pl45m4
      wrote on 4 Mar 2022, 16:37 last edited by
      #5

      @IknowQT said in How to apply qss to a custom class:

      usrCntrListWidget
      {
      border: 4px solid #B8BCBF;
      }

       QListWidget#usrCntrListWidget
      {
       border: 4px solid #B8BCBF;
      }
      

      If debugging is the process of removing software bugs, then programming must be the process of putting them in.

      ~E. W. Dijkstra

      D 1 Reply Last reply 4 Mar 2022, 19:33
      1
      • D Offline
        D Offline
        Dan203
        wrote on 4 Mar 2022, 05:52 last edited by
        #2
        
        QListWidget[objectName="usrCntrListWidget"]
        {
            border: 4px solid #B8BCBF;
        }
        
        
        I 1 Reply Last reply 4 Mar 2022, 07:00
        0
        • D Dan203
          4 Mar 2022, 05:52
          
          QListWidget[objectName="usrCntrListWidget"]
          {
              border: 4px solid #B8BCBF;
          }
          
          
          I Offline
          I Offline
          IknowQT
          wrote on 4 Mar 2022, 07:00 last edited by
          #3

          @Dan203

          I ran the program after applying it to qss, but the style does not change.
          But in qt designer style edit the style is applied.

          D 1 Reply Last reply 4 Mar 2022, 16:13
          0
          • I IknowQT
            4 Mar 2022, 07:00

            @Dan203

            I ran the program after applying it to qss, but the style does not change.
            But in qt designer style edit the style is applied.

            D Offline
            D Offline
            Dan203
            wrote on 4 Mar 2022, 16:13 last edited by
            #4

            @IknowQT

            Hmmm… I just used it yesterday and it worked. Only reason I replied is because I had literally just used it. I'm not a qss expert so I honestly don’t know why it didn’t work for you. 🤷‍♂️

            1 Reply Last reply
            0
            • I IknowQT
              4 Mar 2022, 04:07

              We have created a usrCntrListWidget class that inherits from Qlistwidget.
              I declared in qss to apply qss. The declaration is:

              usrCntrListWidget
              {
              border: 4px solid #B8BCBF;
              }
              

              I declared this, but the style is not applied.

              But

              QListWidget
              {
              border: 4px solid #B8BCBF;
              }
              

              If declared as , the style is applied.

              P Offline
              P Offline
              Pl45m4
              wrote on 4 Mar 2022, 16:37 last edited by
              #5

              @IknowQT said in How to apply qss to a custom class:

              usrCntrListWidget
              {
              border: 4px solid #B8BCBF;
              }

               QListWidget#usrCntrListWidget
              {
               border: 4px solid #B8BCBF;
              }
              

              If debugging is the process of removing software bugs, then programming must be the process of putting them in.

              ~E. W. Dijkstra

              D 1 Reply Last reply 4 Mar 2022, 19:33
              1
              • P Pl45m4
                4 Mar 2022, 16:37

                @IknowQT said in How to apply qss to a custom class:

                usrCntrListWidget
                {
                border: 4px solid #B8BCBF;
                }

                 QListWidget#usrCntrListWidget
                {
                 border: 4px solid #B8BCBF;
                }
                
                D Offline
                D Offline
                Dan203
                wrote on 4 Mar 2022, 19:33 last edited by
                #6

                @Pl45m4

                This is the better way to do it 👍

                1 Reply Last reply
                0
                • I IknowQT
                  4 Mar 2022, 04:07

                  We have created a usrCntrListWidget class that inherits from Qlistwidget.
                  I declared in qss to apply qss. The declaration is:

                  usrCntrListWidget
                  {
                  border: 4px solid #B8BCBF;
                  }
                  

                  I declared this, but the style is not applied.

                  But

                  QListWidget
                  {
                  border: 4px solid #B8BCBF;
                  }
                  

                  If declared as , the style is applied.

                  J Offline
                  J Offline
                  JonB
                  wrote on 4 Mar 2022, 21:12 last edited by
                  #7

                  @IknowQT
                  You asked the same question and I gave you the answer in https://forum.qt.io/topic/134744/promote-the-main-widget-to-another-widget/2, which you ignored. Seems pointless answering, shame.

                  1 Reply Last reply
                  0

                  1/7

                  4 Mar 2022, 04:07

                  • Login

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