Qt Forum

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

    Unsolved QFileDialog restrict for the users only the respective path

    General and Desktop
    3
    4
    3387
    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.
    • Pradeep Kumar
      Pradeep Kumar last edited by

      Hi,

      I am using QFileDialog to save a file , i want to restrict the users to not to open any of the folders , apart from the folders which we specify in the code.

      Ex: C:/Users/Documents/QT

      and can we disable the other widgets in QFileDialog once the dialog opens, with the path specified.?.

      ```
      

      QString strFileName;

      QFileDialog oQFiledialog(this);
      oQFiledialog.setFixedSize(200,200);
      oQFiledialog.setObjectName("Hello");
      //    oQFiledialog.setFileMode(QFileDialog::ExistingFiles);
      
      strFileName = oQFiledialog.getOpenFileName(this,"","C:/Users/Documents/QT");
      
      
      Thanks,

      Pradeep Kumar
      Qt,QML Developer

      1 Reply Last reply Reply Quote 0
      • R
        racerXali last edited by

        u can create a slot like dirchanged(QString dir), connect your file dialog's current changed signal to it :

        connect(m_Fdialog,SIGNAL(currentChanged(QString)),SLOT(dirchanged(QString)));
        

        and set the directory back to your desired path:

        void Dialog::dirchanged(QString dir)
         {
             m_Fdialog->setDirectory("<your specific DIR path>");
         }
        

        this way you'll always end up in the same directory.

        1 Reply Last reply Reply Quote 1
        • H
          Hung Tran last edited by

          I can use:
          QFileDialog dialog(this);
          connect(&dialog, SIGNAL(directoryEntered(const QString &)), this, SLOT(onFileDialogDirectoryChanged(const QString &)));

          1 Reply Last reply Reply Quote 0
          • R
            racerXali last edited by

            u can create a slot like dirchanged(QString dir), connect your file dialog's current changed signal to it :
            connect(m_Fdialog,SIGNAL(currentChanged(QString)),SLOT(dirchanged(QString)));
            and set the directory back to your desired path:
            void Dialog::dirchanged(QString dir)
            {
            m_Fdialog->setDirectory("<your specific DIR path>");
            }
            this way you'll always end up in the same directory.

            @Hung-Tran yours is better so i changed mine

            connect(m_Fdialog,SIGNAL(directoryEntered(QString)),SLOT(dirchanged(QString)));
            void Dialog::dirchanged(QString dir)
             {
                 m_Fdialog->setDirectory("<your specific DIR path>");
             }
            
            1 Reply Last reply Reply Quote 0
            • First post
              Last post