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. [SOLVED] Error while trying to add Icon to QPushButton
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] Error while trying to add Icon to QPushButton

Scheduled Pinned Locked Moved General and Desktop
qiconqpushbuttonerrordesktop
3 Posts 2 Posters 1.8k Views 2 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.
  • A Offline
    A Offline
    Aram
    wrote on 9 Sept 2015, 11:11 last edited by Aram 9 Sept 2015, 11:40
    #1

    Hi there,
    I have the following simple code

    micon=new QIcon(QIcon::fromTheme("arrow-down"));
    button->setIcon(micon);
    

    Where

    QPushButton *button;
    QIcon *micon;
    

    are described in the header file.
    And when I'm trying to compile the compiler gives me an error message

    ERROR: no matching function for call to 'QPushButton::setIcon(QIcon*&)
    

    But it is ok for the compiler to write

    button->setIcon(QIcon::fromTheme("arrow-down"));
    

    and don't use "micon" variable.
    I am totally new to Qt so if someone can explain this to me I'll be really grateful.
    Thanks :)

    A 1 Reply Last reply 9 Sept 2015, 11:23
    0
    • A Aram
      9 Sept 2015, 11:11

      Hi there,
      I have the following simple code

      micon=new QIcon(QIcon::fromTheme("arrow-down"));
      button->setIcon(micon);
      

      Where

      QPushButton *button;
      QIcon *micon;
      

      are described in the header file.
      And when I'm trying to compile the compiler gives me an error message

      ERROR: no matching function for call to 'QPushButton::setIcon(QIcon*&)
      

      But it is ok for the compiler to write

      button->setIcon(QIcon::fromTheme("arrow-down"));
      

      and don't use "micon" variable.
      I am totally new to Qt so if someone can explain this to me I'll be really grateful.
      Thanks :)

      A Offline
      A Offline
      Aram
      wrote on 9 Sept 2015, 11:23 last edited by
      #2

      sorry for stupid thread... I didnt think much about before posting.. fixed already...

      M 1 Reply Last reply 9 Sept 2015, 11:29
      0
      • A Aram
        9 Sept 2015, 11:23

        sorry for stupid thread... I didnt think much about before posting.. fixed already...

        M Offline
        M Offline
        mrjj
        Lifetime Qt Champion
        wrote on 9 Sept 2015, 11:29 last edited by
        #3

        @Aram
        Its completely ok.
        Just mark it as SOLVED and all will be happy

        1 Reply Last reply
        1

        2/3

        9 Sept 2015, 11:23

        • Login

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