Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Get children of QFileDialog derived class
Forum Update on Monday, May 27th 2025

Get children of QFileDialog derived class

Scheduled Pinned Locked Moved Unsolved General and Desktop
qfiledialog
3 Posts 3 Posters 771 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.
  • G Offline
    G Offline
    GrahamLa
    wrote on last edited by
    #1

    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

    jsulmJ 1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Qt Champions 2022
      wrote on last edited by
      #2

      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
      1
      • G GrahamLa

        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

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #3

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

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

        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