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]can not declare QIcon in class?
Forum Updated to NodeBB v4.3 + New Features

[SOLVED]can not declare QIcon in class?

Scheduled Pinned Locked Moved General and Desktop
11 Posts 4 Posters 3.6k 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.
  • F Offline
    F Offline
    Franzk
    wrote on last edited by
    #2

    uh. Show some code?

    "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

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

    1 Reply Last reply
    0
    • V Offline
      V Offline
      vinb
      wrote on last edited by
      #3

      Ok,

      In .h:
      @
      private:
      QIcon icon; //makes the program crash.
      OR
      QIcon *icon//also crashes.
      @

      In a normal function it works like a charme.

      1 Reply Last reply
      0
      • F Offline
        F Offline
        Franzk
        wrote on last edited by
        #4

        Just for kicks, change the name to m_icon and see what happens.

        Obviously it isn't just the fact that you do @QIcon *icon@ in some header. There is more to this. The code snippet you showed is just as good as the description you gave. If the above doesn't work, we will need a lot more context to the problem.

        "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

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

        1 Reply Last reply
        0
        • R Offline
          R Offline
          renato.filho
          wrote on last edited by
          #5

          can you produce a small example with this problem? (only a small class with QIcon)

          1 Reply Last reply
          0
          • V Offline
            V Offline
            vinb
            wrote on last edited by
            #6

            Hi Franzk,

            I'm sorry if i'm not clear here, so i try to explain myself a little better now.

            I'm writing a little test program where i want to have a icon shown in a listview.

            if i use a function call like:
            @ QStandardItem *item = new QStandardItem;
            item->setIcon(QIcon(":/icon/pic5"));@
            then everything works like a charme.
            If i do :
            @ QStandardItem *item = new QStandardItem;
            QIcon proeficon(":/icon/pic5");
            item->setIcon(proeficon);@
            everything works like a charme.
            If i do:
            @ QStandardItem *item = new QStandardItem;
            QIcon proeficon;
            proeficon.addFile(":/icon/pic5");

            item->setIcon(proeficon);@
            

            everything works like a charme.

            But if i do:

            In header:
            @
            QIcon proeficon;
            @
            And in the constructor:
            @
            proeficon.addFile(":/icon/pic5");@
            Then my program crashes.

            I hope i did explain it better now?

            1 Reply Last reply
            0
            • D Offline
              D Offline
              dangelog
              wrote on last edited by
              #7

              Paste a complete, small, compilable testacase.

              Software Engineer
              KDAB (UK) Ltd., a KDAB Group company

              1 Reply Last reply
              0
              • V Offline
                V Offline
                vinb
                wrote on last edited by
                #8

                Recall:
                i just made a small example with only a qicon in the class, but the problem didnt accure.
                So i have to puzzle a little bit more, to narrow the problem down.

                1 Reply Last reply
                0
                • V Offline
                  V Offline
                  vinb
                  wrote on last edited by
                  #9

                  Solved:
                  Very strange,
                  I just copied the whole class to another one and it worked like expected. So there was nothing wrong with the code.
                  So i deleted the whole build folder to force creator to build again and everything worked perfectly after that.
                  Does somebody know what was going on here?

                  1 Reply Last reply
                  0
                  • F Offline
                    F Offline
                    Franzk
                    wrote on last edited by
                    #10

                    Sometimes you just need to rebuild...

                    "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

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

                    1 Reply Last reply
                    0
                    • V Offline
                      V Offline
                      vinb
                      wrote on last edited by
                      #11

                      i thought that i had done that, but clearly not

                      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