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
QtWS25 Last Chance

Get children of QFileDialog derived class

Scheduled Pinned Locked Moved Unsolved General and Desktop
qfiledialog
3 Posts 3 Posters 764 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 6 Mar 2019, 11:46 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

    J 1 Reply Last reply 6 Mar 2019, 12:58
    0
    • D Offline
      D Offline
      dheerendra
      Qt Champions 2022
      wrote on 6 Mar 2019, 12:28 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
        6 Mar 2019, 11:46

        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

        J Offline
        J Offline
        jsulm
        Lifetime Qt Champion
        wrote on 6 Mar 2019, 12:58 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

        1/3

        6 Mar 2019, 11:46

        • Login

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