Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. [Solved] SetIcon not working for a QPushButton
Forum Updated to NodeBB v4.3 + New Features

[Solved] SetIcon not working for a QPushButton

Scheduled Pinned Locked Moved QML and Qt Quick
7 Posts 4 Posters 7.2k 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.
  • E Offline
    E Offline
    Endless
    wrote on 21 Oct 2011, 18:51 last edited by
    #1

    I have the following code snippet for defining a QPushButton and putting it on my window:
    @
    manAutoButton = new QPushButton(this);
    QPixmap pixmap(":/MonitorWindowPix/Manual Icon.png");
    QIcon buttonicon(pixmap);
    manAutoButton->setIcon(buttonicon);
    manAutoButton->move(629, 270);
    @
    When I try to run it, I get a compilation error saying that QPushButton has no member named SetIcon. Qt documentation verifies that QPushButton has the SetIcon member. What's wrong with this code?

    1 Reply Last reply
    0
    • E Offline
      E Offline
      Eddy
      wrote on 21 Oct 2011, 19:39 last edited by
      #2

      buttonicon is not a const QIcon?

      Qt Certified Specialist
      www.edalsolutions.be

      1 Reply Last reply
      0
      • E Offline
        E Offline
        Endless
        wrote on 21 Oct 2011, 19:52 last edited by
        #3

        I can make one or both of pixmap and buttonicon const, but I still get the error telling me that SetIcon is not a member of QPushButton.

        1 Reply Last reply
        0
        • E Offline
          E Offline
          Eddy
          wrote on 21 Oct 2011, 20:38 last edited by
          #4

          Line 2 :
          @
          QPixmap pixmap(":/MonitorWindowPix/Manual Icon.png");
          @
          Should be
          @
          QPixmap pixmap(":/MonitorWindowPix/Manual/Icon.png");
          @
          With the /

          Qt Certified Specialist
          www.edalsolutions.be

          1 Reply Last reply
          0
          • G Offline
            G Offline
            goetz
            wrote on 21 Oct 2011, 21:37 last edited by
            #5

            You write of SetIcon in you posts, but have setIcon in your code (lower/upper case s/S). Which one do you actually use?

            PS:
            Of which type is the pointer manAutoButton?

            http://www.catb.org/~esr/faqs/smart-questions.html

            1 Reply Last reply
            0
            • A Offline
              A Offline
              andre
              wrote on 22 Oct 2011, 10:36 last edited by
              #6

              [quote author="Eddy" date="1319229513"]Line 2 :
              @
              QPixmap pixmap(":/MonitorWindowPix/Manual Icon.png");
              @
              Should be
              @
              QPixmap pixmap(":/MonitorWindowPix/Manual/Icon.png");
              @
              With the /
              [/quote]
              Why is that? Since when are spaces in file names not supported anymore?

              1 Reply Last reply
              0
              • E Offline
                E Offline
                Eddy
                wrote on 22 Oct 2011, 12:14 last edited by
                #7

                Ok my mistake.

                I tend to avoid spaces in filenames. A long time ago i worked on DOS ;)

                Qt Certified Specialist
                www.edalsolutions.be

                1 Reply Last reply
                0

                1/7

                21 Oct 2011, 18:51

                • Login

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