QFileDialog restrict for the users only the respective path
-
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,
-
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.
-
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>"); }