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