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 Stylsheet ID Selector does not work
Forum Updated to NodeBB v4.3 + New Features

Qt Stylsheet ID Selector does not work

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 2 Posters 2.3k 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.
  • QT-static-prgmQ Offline
    QT-static-prgmQ Offline
    QT-static-prgm
    wrote on last edited by
    #1

    Hi,

    i played a bit around with the Stylesheet. I write everything to a txt file and set it here in my MainWindow

    My QActions are added in this function. I linked to the important one.
    As you can see i set the property name to test123 and specified it in my stylesheet. But it is not black. It has no colour.
    i also tried to make the hover border colour different, but it does not work, either.

    Is there someone how knows why the id selector does not work??

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mostefa
      wrote on last edited by
      #2

      Helllo @QT-static-prgm

      According to Qt documentation Stylesheet, id selector should be replaced with an object name of a widget :

      http://doc.qt.io/qt-4.8/stylesheet-syntax.html#selector-types

      ID Selector QPushButton#okButton Matches all QPushButton instances whose object name is okButton.

      I think that your mistake is that you are trying to try to use Id selector with QAction ( and QAction is not a widget, QAction does not even have a setStylesheet() function)

      1 Reply Last reply
      2
      • QT-static-prgmQ Offline
        QT-static-prgmQ Offline
        QT-static-prgm
        wrote on last edited by
        #3

        @mostefa oops. Thank you. I got it working now. But how can i add a image for an QToolButton??

        QToolButton#test123:checked {
        	image: url(:/images/toolbar/about.png);
        }
        
        QToolButton#test123 {
        	border-image: url(:/images/toolbar/about.png);
        	border-style: solid;
        	border-width: 1px;
        	border-radius: 5px;
        	border-color: #a4daff;
        	min-height: 25px
        }
        

        For the checked state image works fine. But for not checked only background and border image work. But that's not what i want.

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mostefa
          wrote on last edited by
          #4

          @QT-static-prgm

          What if you write this for the unchecked state ?

          QToolButton#test123:unchecked {
          	border-image: url(:/images/toolbar/about.png);
          	border-style: solid;
          	border-width: 1px;
          	border-radius: 5px;
          	border-color: #a4daff;
          	min-height: 25px
          }
          
          1 Reply Last reply
          0
          • M Offline
            M Offline
            mostefa
            wrote on last edited by mostefa
            #5

            Also on the unchecked state you choosed to put image only on border with border-image property, maybe you want to put your image like checked state? in this case you have just to add :

            image: url(:/images/toolbar/about.png);
            

            on unchecked state stylesheet

            1 Reply Last reply
            0
            • QT-static-prgmQ Offline
              QT-static-prgmQ Offline
              QT-static-prgm
              wrote on last edited by
              #6

              @mostefa that's what did not work. But i found the problem. image works only if there is a border-style.
              setting border-style: none works fine

              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