Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved Get children of QFileDialog derived class

    General and Desktop
    qfiledialog
    3
    3
    468
    Loading More Posts
    • 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.
    • G
      GrahamLa last edited by

      Hi
      I have derived a class from QFileDialog -

      class PrintFileDialog : public QFileDialog
      {
      public:
      	PrintFileDialog(QWidget *parent);
      	~PrintFileDialog();
      
      	void func();
      };
      
      #include "PrintFileDialog.h"
      
      PrintFileDialog::PrintFileDialog(QWidget *parent)
      {
      }
      
      
      PrintFileDialog::~PrintFileDialog()
      {
      }
      
      void PrintFileDialog::func()
      {
      	QList<QObject*> widgets = this->children();
      	int a;
      	a = 10;
      
      }
      

      When func() is called the widgets list is empty.
      What is the correct way to do this

      Thanks

      jsulm 1 Reply Last reply Reply Quote 0
      • dheerendra
        dheerendra Qt Champions 2022 last edited by

        Internal objects will not be created unless you call show or exec. Here you are calling in constructor. Hence you don't see the children.

        Dheerendra
        @Community Service
        Certified Qt Specialist
        http://www.pthinks.com

        1 Reply Last reply Reply Quote 1
        • jsulm
          jsulm Lifetime Qt Champion @GrahamLa last edited by

          @GrahamLa Where and when do you call func()?

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply Reply Quote 0
          • First post
            Last post