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. QIcon; how to change the state and mode?

QIcon; how to change the state and mode?

Scheduled Pinned Locked Moved General and Desktop
5 Posts 4 Posters 11.3k Views
  • 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.
  • K Offline
    K Offline
    Kewal
    wrote on last edited by
    #1

    I was creating many icons and adding QIcon to the tool button,

    @
    QIcon icon;
    icon.addFile(":/IconNormal.png", QSize(), QIcon::Normal, QIcon::On);
    icon.addFile(":/IconActive.png", QSize(), QIcon::Active, QIcon::On);
    icon.addFile(":/IconSelected.png", QSize(), QIcon::Selected, QIcon::On);
    icon.addFile(":/IconDisabled.png", QSize(), QIcon::Disabled, QIcon::On);
    @

    Now if i want to change the state of the button , how should i achieve that, there is no method to change the state of the button.

    [EDIT: code formatting, please wrap in @-tags, Volker]

    1 Reply Last reply
    0
    • K Offline
      K Offline
      koahnig
      wrote on last edited by
      #2

      Have a look to this "example":http://qt-project.org/doc/qt-4.8/widgets-icons.html

      Vote the answer(s) that helped you to solve your issue(s)

      1 Reply Last reply
      0
      • K Offline
        K Offline
        Kewal
        wrote on last edited by
        #3

        I have seen that example but Its just not striking me as to how to get the disabled state or selected state as an icon, All i see is the normal state always,. what if I want to modify the the way the selected icon looks,. (I guess QIconEngine class needs to be involved, but still). I am simpoly not able to get the Icons example and its pretty strange the when you select the disabled from the drop down box the disabled become active. now what does it mean

        1 Reply Last reply
        0
        • A Offline
          A Offline
          andre
          wrote on last edited by
          #4

          What do you mean with "there is no method to change the state of the button"? Of course there is! Check out the enabled and checked properties. Furthermore, can can control if the button has focus or not. A button cannot be selected, so that state is useless for buttons. It is useful for icons in an item view or something like that though.

          1 Reply Last reply
          0
          • G Offline
            G Offline
            Gouba
            wrote on last edited by
            #5

            For the tool button you must use "On" and "Off" states to show checked propertie, here is an example:

            @
            toolButton = new QToolButton;
            toolButton->setCheckable(true);
            QIcon qIcon;
            qIcon.addFile(":/Icons/images/icon_off.png",QSize(32,32),QIcon::Normal,QIcon::On);
            qIcon.addFile(":/Icons/images/icon_on.png",QSize(32,32),QIcon::Normal,QIcon::Off);
            toolButton->setIcon(qIcon);
            @

            Hope this help you.

            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