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. QToolbar Extension Button Stylesheet
Qt 6.11 is out! See what's new in the release blog

QToolbar Extension Button Stylesheet

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 1.4k 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.
  • J Offline
    J Offline
    jineshmehta
    wrote on last edited by
    #1

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

    Thanks in advance.

    1 Reply Last reply
    0
    • B Offline
      B Offline
      Bonnie
      wrote on last edited by Bonnie
      #2

      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.

      QToolButton#qt_toolbar_ext_button{qproperty-icon:url(your_custom_image_url)}
      

      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
      {
        public:
          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.

      1 Reply Last reply
      3

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved