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. Style Sheets: QRadioButton::setIcon() conflicts with icon set in stylesheet?
Qt 6.11 is out! See what's new in the release blog

Style Sheets: QRadioButton::setIcon() conflicts with icon set in stylesheet?

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 3.0k Views 1 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.
  • T Offline
    T Offline
    thEClaw
    wrote on last edited by
    #1

    I am trying to style the QRadioButtons/QCheckBoxes in my application. For using custom icons, the documentation says something like this:
    @QRadioButton::indicator::unchecked {
    image: url(:/images/radiobutton_unchecked.png);
    }@

    Which is fine so far. But some QRadioButtons come with an icon, and so do some of the QCheckBoxes. Now their icon is being overlayed by the one set in the stylesheet.
    Is there something I can do to differentiate between QRadioButtons/QCheckBoxes that already have an icon and ones that come without one?

    EDIT : I am using "generated" QRadioButtons etc., meaning that they are based off of a QAction. Maybe that causes the "double icon"?

    1 Reply Last reply
    0
    • R Offline
      R Offline
      RavensAngel
      wrote on last edited by
      #2

      Hi,

      what do you mean with some of them come with an icon ?

      Anywhay this is how i styled a checkbox before, which works perfectly. Ofcourse some attributes you won't need, but anyways:

      @
      QCheckBox{
      font-family: "Arial";
      font-size: 20px;
      font-style: normal;
      font-weight: bold;
      border-style: none;
      }

      QCheckBox::indicator {
      width: 64px;
      height: 64px;
      }

      QCheckBox::indicator:unchecked {
      image: url(:/images/checkbox_unchecked.png);
      }

      QCheckBox::indicator:unchecked:hover {
      image: url(:/images/checkbox_unchecked_hover.png);
      }

      QCheckBox::indicator:checked {
      image: url(:/images/checkbox_checked.png);
      }

      QCheckBox::indicator:checked:hover {
      image: url(:/images/checkbox_checked_hover.png);
      }

      @

      1 Reply Last reply
      0
      • T Offline
        T Offline
        thEClaw
        wrote on last edited by
        #3

        If I e.g. make a QAction (including icon) checkable, it act's like a QCheckBox with an icon (no style sheet involved yet). Now inside the style sheet I set another icon, and both lay on top of each other, which is obviously very ugly.

        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