Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. QToolButton StyleSheet not Accepting PNG
Forum Updated to NodeBB v4.3 + New Features

QToolButton StyleSheet not Accepting PNG

Scheduled Pinned Locked Moved Solved Qt Creator and other tools
5 Posts 2 Posters 1.3k 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.
  • S Offline
    S Offline
    Stevendragoes
    wrote on last edited by
    #1

    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:

    5e083352-7f9d-4310-a2aa-c91e82a3776b-image.png

    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

    JonBJ 1 Reply Last reply
    0
    • S Stevendragoes

      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:

      5e083352-7f9d-4310-a2aa-c91e82a3776b-image.png

      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

      JonBJ Online
      JonBJ Online
      JonB
      wrote on last edited by JonB
      #2

      @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:?

      1 Reply Last reply
      0
      • S Offline
        S Offline
        Stevendragoes
        wrote on last edited by Stevendragoes
        #3

        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

        1 Reply Last reply
        0
        • S Offline
          S Offline
          Stevendragoes
          wrote on last edited by
          #4

          @JonB I figured it out.

          https://doc.qt.io/Qt-5/stylesheet-designer.html this is to integrate to the designer

          and this is the syntax.
          https://doc.qt.io/Qt-5/stylesheet-syntax.html

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

          JonBJ 1 Reply Last reply
          0
          • S Stevendragoes

            @JonB I figured it out.

            https://doc.qt.io/Qt-5/stylesheet-designer.html this is to integrate to the designer

            and this is the syntax.
            https://doc.qt.io/Qt-5/stylesheet-syntax.html

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

            JonBJ Online
            JonBJ Online
            JonB
            wrote on last edited by
            #5

            @Stevendragoes
            As shown in your referenced https://doc.qt.io/Qt-5/stylesheet-designer.html , 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....

            1 Reply Last reply
            1

            • Login

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