Nominate our 2022 Qt Champions!

QToolButton StyleSheet not Accepting PNG

  • Hi All, I want to create a ToolButton and change from Text to Icons/Images because it looked ugly. Hence, when I try to change the stylesheet and add the resource, it says Invalid Style Sheet.
    Screenshot Below:


    Is there a reason why? it is because its PNG? what is the acceptable format of my image so that it is a valid stylesheet for the 3 Tool Buttons created. I want to make it look prettier. Thanks

  • @Stevendragoes
    I don't do this stuff, but aren't you supposed to write:

    image: url(:/imgs/control_play.png)

    ? I am unsure whether or not the whole thing needs to be inside { ... }, but the important thing you are missing is the image:? And if that's not right maybe it's background:?

  • Hello @JonB
    I just dragged the ToolButton from the Widgets into the UI form. I did not initialise or write anything.. I was able to add gradient, Color and font, but not the Pictures

    EDit, I am not able to add gradient or color to the tool button at all. Is there a reason why? I can't do the same for the Push Buttons too

  • @JonB I figured it out. this is to integrate to the designer

    and this is the syntax.

    You won't see it in the UI itself (I am not so sure why) but you will see it when the program loads

  • @Stevendragoes
    As shown in your referenced , the stuff they show from the Designer does correspond to the required stylesheet syntax. And as I said your plain url(:/imgs/control_play.png) does not have an image: or background:. So I don't know how you made what you show work if you did not make the kind of change I suggested. But clearly you know more than I do since you are using it....

Log in to reply