Hello. I want to make different icons for checked and unchecked state of QPushButton. The code:
Qt Code:
  1. MainWindow::MainWindow(QWidget *parent)
  2. : QMainWindow(parent)
  3. {
  4. QBoxLayout *layout1 = new QVBoxLayout();
  5.  
  6. QWidget *widget = new QWidget(this);
  7. widget->setLayout(layout1);
  8. setCentralWidget(widget);
  9.  
  10. QIcon icon1;
  11. icon1.addFile(QStringLiteral(":/norecord.png"), QSize(), QIcon::Normal, QIcon::Off);
  12. icon1.addFile(QStringLiteral(":/active.png"), QSize(), QIcon::Normal, QIcon::On);
  13.  
  14. QPushButton *button1 = new QPushButton(this);
  15. button1->setCheckable(true);
  16. button1->setText("Sample Text");
  17. button1->setIcon(icon1);
  18. layout1->addWidget(button1);
  19.  
  20. }
To copy to clipboard, switch view to plain text mode 
I use Qt 5.15.2. This code works in Windows, but not in Linux and Android, there always shows an icon for a unchecked state.
On Qt 5.11.3 and earlier versions it worked.

As far as I could understand, the problem causes this code in the Fusion style, file src/widgets/styles/qfusionstyle.cpp:
Qt Code:
  1. case CE_PushButtonLabel:
  2. if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(option)) {
  3. QStyleOptionButton b(*button);
  4. // no PM_ButtonShiftHorizontal and PM_ButtonShiftVertical for fusion style
  5. b.state &= ~(State_On | State_Sunken);
  6. QCommonStyle::drawControl(element, &b, painter, widget);
  7. }
  8. break;
To copy to clipboard, switch view to plain text mode 
I want to ask: Is it a correct code? Is it a bug or style feature?