Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. How to set icon at different modes?

How to set icon at different modes?

Scheduled Pinned Locked Moved Mobile and Embedded
4 Posts 3 Posters 5.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.
  • M Offline
    M Offline
    Matze5590
    wrote on last edited by
    #1

    Hi,

    I try to change the image of a qpushbutton in disabled mode
    This is just editing the Normal mode.
    @
    setIcon(QIcon(":/images/image.bmp"));
    @

    Thanks

    [edit:syntax hihlight added / Denis Kormalev]

    1 Reply Last reply
    0
    • D Offline
      D Offline
      DenisKormalev
      wrote on last edited by
      #2

      You should create QIcon object and set additional pixmap for QIcon::Mode==Disabled

      1 Reply Last reply
      0
      • C Offline
        C Offline
        cheng
        wrote on last edited by
        #3

        You can use style sheet:
        @
        QPushButton {
        border-image: url(:/images/bouton-retour.png);
        background-color: rgba(255, 255, 255, 0);
        }

        QPushButton::pressed,QPushButton:disabled {
        border-image: url(:/images/bouton-retour-desactive.png);
        }
        @

        [edit: fixed code / chetankjain]

        1 Reply Last reply
        0
        • D Offline
          D Offline
          DenisKormalev
          wrote on last edited by
          #4

          cheng, border-image is not exactly what needed for author. It will fill borders, but not change icon.

          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