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 Updated to NodeBB v4.3 + New Features

QObject::findChildren<>() problem

Scheduled Pinned Locked Moved Solved Qt 6
5 Posts 3 Posters 645 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.
  • V Offline
    V Offline
    VeNToR
    wrote on 22 Oct 2021, 00:12 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...

    E 1 Reply Last reply 22 Oct 2021, 00:17
    0
    • V VeNToR
      22 Oct 2021, 00:12

      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...

      E Offline
      E Offline
      eyllanesc
      wrote on 22 Oct 2021, 00:17 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 22 Oct 2021, 00:19
      0
      • E eyllanesc
        22 Oct 2021, 00:17

        @VeNToR please provide a verifiable example

        V Offline
        V Offline
        VeNToR
        wrote on 22 Oct 2021, 00:19 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
        • C Offline
          C Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on 22 Oct 2021, 06:12 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 22 Oct 2021, 08:59 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

            4/5

            22 Oct 2021, 06:12

            • Login

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