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. Change QAction Icon in StyleSheet?
Forum Updated to NodeBB v4.3 + New Features

Change QAction Icon in StyleSheet?

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 2 Posters 4.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.
  • MarthCrowleyM Offline
    MarthCrowleyM Offline
    MarthCrowley
    wrote on last edited by
    #1

    I have read some things, like I've seen some things,

    I have a QToolBar and QActions with certain icons, i would deign to change these within the .QSS (stylesheet), however it appears that a QAction is not a widget,

    so is there no way to access the QAction icon to change it within a style sheet? and perhaps, without getting to cray, would it be feasible and/or recommended to perhaps set up a function to manually change the icons upon user selection of a stylesheet? Your thoughts?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      You can style the QToolButton that will be generated from your QAction. You can give it an object name and use that in your style sheet.

      Hope it helps

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • MarthCrowleyM Offline
        MarthCrowleyM Offline
        MarthCrowley
        wrote on last edited by
        #3

        could you give me an example? I have been able to successfully change the color of the QAction buttons on the toolbar, however, they all change. this is not helpful when trying to do specific ones.

        I have tried directly calling the names of the QActions objects in the .qss file, but to no avail. I don't understand what you mean by setting an object name to the QAction button though.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Did you try with an ID Selection like shown in this page ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • MarthCrowleyM Offline
            MarthCrowleyM Offline
            MarthCrowley
            wrote on last edited by
            #5

            Yes, of course, I promise you it does not work.

            I know that I can change the icon in code behind, but I wanted to keep it all in the .qss file,

            I have tried to call its name, call it as a property of QToolBar, I have read that it is not possible because a QAction is not a widget and even though it creates a button, it is only as an ancillary ToolBar property, which can only be changed on a macro scale, i.e. all icons can be substituted or no icons, all QAction buttons on a toolbar can have their color changed, but it cannot be a single button, but all buttons.

            I'm just trying to get the official word on this. Everything I tested failed outside of setting up some sort of key and trying to call it from the .qss, but that did not seem to be plausible.

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Did you put the ID on the button created from your action ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              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