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. Set a stylesheet for a toggled button
Forum Updated to NodeBB v4.3 + New Features

Set a stylesheet for a toggled button

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 258 Views 2 Watching
  • 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.
  • S Offline
    S Offline
    Sucharek
    wrote on last edited by
    #1

    Hi, so I wanna set a stylesheet everytime a button is toggled, but I can't seem to figure out how.
    This is what I tried this so far:

    QPushButton::checked{
        background-color: rgb(255, 170, 255);
    }
    
    checked: rgb(255, 170, 255);
    

    None of these work.

    Pl45m4P 1 Reply Last reply
    0
    • S Sucharek

      Hi, so I wanna set a stylesheet everytime a button is toggled, but I can't seem to figure out how.
      This is what I tried this so far:

      QPushButton::checked{
          background-color: rgb(255, 170, 255);
      }
      
      checked: rgb(255, 170, 255);
      

      None of these work.

      Pl45m4P Offline
      Pl45m4P Offline
      Pl45m4
      wrote on last edited by Pl45m4
      #2

      @Sucharek

      Just one :

      QPushButton:checked {........}
      

      Also you probably need to set a custom border style to make your background color visible.

      From documentation:

      Warning: If you only set a background-color on a QPushButton, the background may not appear unless you set the border property to some value. This is because, by default, the QPushButton draws a native border which completely overlaps the background-color


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

      ~E. W. Dijkstra

      S 1 Reply Last reply
      3
      • Pl45m4P Pl45m4

        @Sucharek

        Just one :

        QPushButton:checked {........}
        

        Also you probably need to set a custom border style to make your background color visible.

        From documentation:

        Warning: If you only set a background-color on a QPushButton, the background may not appear unless you set the border property to some value. This is because, by default, the QPushButton draws a native border which completely overlaps the background-color

        S Offline
        S Offline
        Sucharek
        wrote on last edited by
        #3

        Hi @Pl45m4, thanks, it works perfectly.

        1 Reply Last reply
        0

        • Login

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