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. Can't call QObject::setParent()

Can't call QObject::setParent()

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 3 Posters 672 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.
  • K Offline
    K Offline
    kitfox
    wrote on last edited by kitfox
    #1

    I have some code that used to compile and run. However, my latest attempt is refusing to compile. Even though my classes publicly extend QObject, I'm getting errors saying 'class Gf::Attribute' has no member named 'setParent'.

    Infact, even the following code causes 'no member named 'setParent' in 'QObject'':

        QObject* a = new QObject();
        QObject* b = new QObject();
        a->setParent(b);
    

    Even qobject.h doesn't list setParent() as a member. It still appears as a public member function in the docs, though. I'm using Qt 5.12.3. What's going on? Was QObject::setParent() taken out of the API? If so, how do I set the parent?

    JKSHJ 1 Reply Last reply
    0
    • K kitfox

      I have some code that used to compile and run. However, my latest attempt is refusing to compile. Even though my classes publicly extend QObject, I'm getting errors saying 'class Gf::Attribute' has no member named 'setParent'.

      Infact, even the following code causes 'no member named 'setParent' in 'QObject'':

          QObject* a = new QObject();
          QObject* b = new QObject();
          a->setParent(b);
      

      Even qobject.h doesn't list setParent() as a member. It still appears as a public member function in the docs, though. I'm using Qt 5.12.3. What's going on? Was QObject::setParent() taken out of the API? If so, how do I set the parent?

      JKSHJ Offline
      JKSHJ Offline
      JKSH
      Moderators
      wrote on last edited by JKSH
      #2

      @kitfox said in Can't call QObject::setParent():

      Even qobject.h doesn't list setParent() as a member.

      It sounds like your local copy of qobject.h was (accidentally?) modified. QObject::setParent() definitely exists in Qt 5.12.3: https://code.qt.io/cgit/qt/qtbase.git/tree/src/corelib/kernel/qobject.h?h=5.12.3#n204

      A quick fix is to replace your qobject.h with the version in the link above, but this won't repair other files that might have been modified. To be sure that everything is fixed, uninstall and reinstall your copy of Qt 5.12.3.

      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

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

        Reinstalling Qt worked. Thanks.

        I still have no idea what I could have done to corrupt things.

        aha_1980A 1 Reply Last reply
        1
        • K kitfox

          Reinstalling Qt worked. Thanks.

          I still have no idea what I could have done to corrupt things.

          aha_1980A Offline
          aha_1980A Offline
          aha_1980
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @kitfox If you do global rename/refactor, it is possible to modify the Qt or compiler headers too.

          I'd recommend to make them readonly to prevent such accidental changes.

          Regards

          Qt has to stay free or it will die.

          1 Reply Last reply
          4

          • Login

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