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. How can I style a QToolBar extension button icon via CSS
Forum Updated to NodeBB v4.3 + New Features

How can I style a QToolBar extension button icon via CSS

Scheduled Pinned Locked Moved General and Desktop
4 Posts 1 Posters 9.7k 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.
  • U Offline
    U Offline
    Uwe Kindler
    wrote on last edited by
    #1

    When a toolbar is resized in such a way that it is too small to show all the items it contains, an extension button will appear as the last item in the toolbar. Pressing the extension button will pop up a menu containing the items that does not currently fit in the toolbar.

    The extension button shows a small icon of 2 black arrows (looks like >>). I styled my whole application with a drak black style and light grey font colors. The two black arrows of the extension button icon are very bad visible on top of the dark grey background (see the picture below) and I would like to use light grey arrows instead.

    !http://www.cetoni.de/toolbar_extension_button.gif(Picture: toolbar_extension_button.gif)!

    In the Qt docs I did not found any hint how to style the extension button icon and so I searched the Qt sources. I found the following solution that works partly.

    QToolButton#qt_toolbar_ext_button
    {
    qproperty-icon: url(:/styleimg/toolbar_extension_icon.png);
    }

    This gives the extension button a new icon. But as soon as I undock the toolbar and redock it again, the extension button has the old icon again with the two black arrows. One possible solution would be, to reapply the stylesheet as soon as the toolbar is docked again. But this is not a nice solution. Is there any other way to style the extension button, or at least the color of the extension button arrows?

    1 Reply Last reply
    0
    • ? This user is from outside of this forum
      ? This user is from outside of this forum
      Guest
      wrote on last edited by
      #2

      hi,

      while launching the qt application, you can feed it a style sheet (with all controls styled) and this would be inherited all across the application. This way you need to do it only once and then I don't think you would come across this issue. Have you tried this? In spite of this, if the style is lost, then its a bug in Qt

      1 Reply Last reply
      0
      • U Offline
        U Offline
        Uwe Kindler
        wrote on last edited by
        #3

        Hi,

        I already use a global stylesheet for my whole application. The problem is, that there is no subcontrol identifier (like QCheckBox::indicator) to style the icon of the toolbar extension button. Therefore i searched the Qt sources and found the name of the extension button: qt_toolbar_ext_button . Then I used the icon property of the extension button to set a new icon via application stylesheet. The problem is, that the stylesheet is applied only once at application startup. As soon as I undock or redock the toolbar, it overwrites my stylesheet icon with its own icon. That means I would need to reload the styelesheet for the toolbar everytime I dock and undock the toolbar. This is not a satisfying solution.

        1 Reply Last reply
        0
        • ? This user is from outside of this forum
          ? This user is from outside of this forum
          Guest
          wrote on last edited by
          #4

          yes i wrote a small test prog and was able to replicate your problem. the actual behavior I noticed is as follows:
          when you undock if you ensure that the toolbar remains horizontal always, you still get back the custom icon, if the toolbar becomes vertical and then you try to dock it and resize, the custom icon is lost and the default is back. to check further ...

          seems a bug to me, you should log this bug.

          1 Reply Last reply
          0

          • Login

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