Important: Please read the Qt Code of Conduct -

Unable to overwrite widget->setStyleSheet wtih QApplication->setStyleSheet

  • I do the following in my application, where button_toggleSearchAreaResults is a QToolButton:

    button_toggleSearchAreaResults->setStyleSheet( QStringLiteral( "QToolButton::on{border-image:url(:/icons/1downarrow_grey.png);} "
    "QToolButton{border-image:url(:/icons/1rightarrow_grey.png);}" ) );

    This gets me my images OK. Then, I'd like to overwrite them from QApplication->setStyleSheet, so I call it with:

       background-color: none;
       border-image: none;
       border-image: url(rightlocationhere/qdarkstyle/rc/down_arrow_disabled.png);
       border-image: url(rightlocationhere/qdarkstyle/rc/right_arrow.png);
       border-image: url(rightlocationhere/qdarkstyle/rc/down_arrow.png);

    If I don't have my widget->setStyleSheet call, QApplication->setStyleSheet works fine. If I do, it's not able to overwrite the border-image property - how come?

  • Qt Champions 2017

    Widget style sheet has precedence over qapplication style sheet. Hence u r seeing this issue

Log in to reply