QToolbar Extension Button Stylesheet

  • How can I change the icon of QToolbar Extension Tool button Icon from ">>" to something custom?

    Thanks in advance.

  • AFAIK, there's no stylesheet for that button icon.

    A cheating way is to set the icon property by the object name written in the Qt source code.


    But the icon will be reset when toolbar's orientation changed, so if your toolbar's orientation may change, you need to connect to orientationChanged signal and set the stylesheet again.

    Note: The above method may become invalid if Qt changes the source code in the future.

    Another way is to implement a QProxyStyle and set it to be the application's style.

    class MyProxyStyle : public QProxyStyle
        QIcon standardIcon(QStyle::StandardPixmap standardIcon, const QStyleOption *option = nullptr,
                           const QWidget *widget = nullptr) const override
            if(standardIcon == QStyle::SP_ToolBarHorizontalExtensionButton)
                return QIcon("your_custom_image_url_for_horizontal");
            else if (standardIcon == QStyle::SP_ToolBarVerticalExtensionButton)
                return QIcon("your_custom_image_url_for_vertical");
            return QProxyStyle::standardIcon(standardIcon, option, widget);
    int main(int argc, char *argv[])
        QApplication a(argc, argv);
        a.setStyle(new MyProxyStyle);
        return a.exec();

    Note: This will work on all toolbars in the application.

Log in to reply