Created
September 6, 2017 11:08
-
-
Save blazovics/d12288867f1bf745612fe710233df219 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
QObject* findItemByName(QList<QObject*> nodes, const QString& name) | |
{ | |
for(int i = 0; i < nodes.size(); i++) | |
{ | |
// Node keresése | |
if (nodes.at(i) && nodes.at(i)->objectName() == name) | |
{ | |
return nodes.at(i); | |
} | |
// Gyerekekben keresés | |
else if (nodes.at(i) && nodes.at(i)->children().size() > 0) | |
{ | |
QObject* item = findItemByName(nodes.at(i)->children(), name); | |
if (item) | |
return item; | |
} | |
} | |
return nullptr; | |
} | |
QObject* findItemByName(QObject *rootObject, const QString& name) | |
{ | |
Q_ASSERT(rootObject != nullptr); | |
if (rootObject->objectName() == name) | |
{ | |
return (QObject*)rootObject; | |
} | |
return findItemByName(rootObject->children(), name); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment