Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. General talk
  3. Qt 6
  4. QObject::findChildren<>() problem
Forum Update on Monday, May 27th 2025

QObject::findChildren<>() problem

Scheduled Pinned Locked Moved Solved Qt 6
5 Posts 3 Posters 489 Views
  • 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.
  • V Offline
    V Offline
    VeNToR
    wrote on last edited by
    #1

    Hi all !

    My class derived as QQmlPropertyMap<-MyClass1<-MayClass2.

    When try in parent function;

    findChildren<MyClass2*>(); // returns empty list
    findChildren<MyClass1*>(); // returns empty list
    findChildren<QQmlPropertyMap*>(); // returns list of created QQmlPropertyMap objects of parent.

    Any suggestions ?

    Thanks...

    eyllanescE 1 Reply Last reply
    0
    • V VeNToR

      Hi all !

      My class derived as QQmlPropertyMap<-MyClass1<-MayClass2.

      When try in parent function;

      findChildren<MyClass2*>(); // returns empty list
      findChildren<MyClass1*>(); // returns empty list
      findChildren<QQmlPropertyMap*>(); // returns list of created QQmlPropertyMap objects of parent.

      Any suggestions ?

      Thanks...

      eyllanescE Offline
      eyllanescE Offline
      eyllanesc
      wrote on last edited by
      #2

      @VeNToR please provide a verifiable example

      If you want me to help you develop some work then you can write to my email: e.yllanescucho@gmal.com.

      V 1 Reply Last reply
      0
      • eyllanescE eyllanesc

        @VeNToR please provide a verifiable example

        V Offline
        V Offline
        VeNToR
        wrote on last edited by VeNToR
        #3

        @eyllanesc said in QObject::findChildren<>() problem:

        please provide a verifiable example

        thank you your reply but codes of classes very long... but I can say all classes has Q_OBJECT, registered by Q_DECLARE_METATYPE and qRegisterMetaType.

        1 Reply Last reply
        0
        • Christian EhrlicherC Offline
          Christian EhrlicherC Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @VeNToR said in QObject::findChildren<>() problem:

          but codes of classes very long...

          Then remove everything unneded then your code is imo not longer than 20 lines. 2 classes simply derived from QQmlPropertyMap / MyClass1, one main function which instantiates those classes and does a findChildren<>.

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          1 Reply Last reply
          0
          • V Offline
            V Offline
            VeNToR
            wrote on last edited by
            #5

            Thanks, I solved ! Such as follows;

            template <
            typename _MyClass2>
            MyClass1::MyClass1(
            MyClass2 MyObject // !!! DO NOT USE QObject !!!
            QObject* ChParent /= Q_NULLPTR/)
            : QQmlPropertyMap(
            MyObject,
            ChParent)

            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