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. QWidgets and css file
Qt 6.11 is out! See what's new in the release blog

QWidgets and css file

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

    Hi. I'm using a css file, instead to use setStyleSheet function of each components.
    The css file permits to set the styleSheet globally.
    Is there a way to insert in the css file a style for a particular object for example for a MyButton01 object in the main form?

    Need programmers to hire?
    www.labcsp.com
    www.denisgottardello.it
    GMT+1
    Skype: mrdebug

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by mrjj
      #2

      Hi
      Yes, you can just use selectors
      if the button is names MyButton01
      you can do
      QPushButton#MyButton01 {
      }
      to apply to buttons named MyButton01

      Please see
      http://doc.qt.io/qt-5/stylesheet-syntax.html
      and Selector Types.

      I also use 1 single stylesheet ( as i qres file)
      i set on QApplication and then use
      names / types to target the ones i want without setting it directly on the widgets.
      This is FAR easier to control over time as stylesheets
      on each widgets becomes a mess very fast :)

      If you only want to apply to pushbuttons in the mainform, you can use
      QMainwindow > QPushButton meaning the pushbutton must be a child ( ownerwise)
      of a MainWindow type.

      1 Reply Last reply
      3
      • mrdebugM Offline
        mrdebugM Offline
        mrdebug
        wrote on last edited by
        #3

        Perfect!

        Need programmers to hire?
        www.labcsp.com
        www.denisgottardello.it
        GMT+1
        Skype: mrdebug

        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