qtqtstylesheetsqstylesheet

QToolButton accepts Hover in disabled state?


I have that icon:
enter image description here


This is QToolButton's inheritor without overrided paint event, actually I'm working right in the Qt Designer right now.
It has some overloaded styles:

MyToolButton {
  border-style: none;
  padding-right: 14px;
  border-radius: 1.5px;
}

MyToolButton:hover {
  background-color: rgb(220, 224, 228);
}

MyToolButton:hover:focus {
  background-color: rgb(220, 224, 228);
}

MyToolButton:pressed {
  background-color: rgb(193, 201, 208);
}

MyToolButton:pressed:focus {
  background-color: rgb(193, 201, 208);
}

MyToolButton:menu-arrow {
  image: url(:/Images/i13_down_arrow_combo.png);
}

MyToolButton:menu-arrow:disabled {
  image: url(:/Images/i13_down_arrow_combo_disabled.png);
  outline: none;
  border: 0px;
}

MyToolButton::menu-button {
  border-radius: 0px;
  border: 1px solid transparent;
  padding-right: 2px;
  padding-left: 2px;
  width: 8px;
}

MyToolButton::menu-button:pressed {
  border-top: 1px solid rgb(169, 180, 190);
  border-right: 1px solid rgb(169, 180, 190);
  border-bottom: 1px solid rgb(169, 180, 190);
  border-top-right-radius: 1.5px;
  border-bottom-right-radius: 1.5px;
}

MyToolButton::menu-button:pressed:focus {
  outline: none;
  border: 0px;
  padding-right: 3px;
}

MyToolButton[isMenuShown="false"]::menu-button:pressed:focus
{ 
  background-color: rgb(220, 224, 228);
}


MyToolButton[isMenuShown="true"]::menu-button:pressed:focus
{
  background-color: rgb(193, 201, 208);
}

The button is in disabled state, but it reacts on hover!
Here is hovered icon:
enter image description here

What I need to do is to remove border that is shown on hover.
I've tried a lot of variants like hover:disabled overloading and other stuff.
Could anyone please help?


Solution

  • Found that trouble. I have custom class MyToolButton exported to Qt Designer.
    It has overloaded paintEvent that lokks like:

    void MyToolButton::paintEvent(QPaintEvent* event) {
      QToolButton::paintEvent(event);
      if (<some condition>)
      else if (underMouse()) // <-----NO isEnabled() here
          drawSolidBorder ... ///
      else if (<some condition>)
          drawSolidBorder ... ///
    }
    

    So that's it.