Are there any signals emitted when creating or opening a directory with QFileDialog::getExistingDirectory?

StackOverflow https://stackoverflow.com//questions/9672045

  •  12-12-2019
  •  | 
  •  

Question

I use something like:

CreateChooseDir() 
{ 

QString OpenedCreatedDirectory = QFileDialog::getExistingDirectory(this, tr("Choose Directory"),
                                                              "/home",
                                                              QFileDialog::DontResolveSymlinks | QFileDialog::DontUseNativeDialog);


    ui.PathLineEdit -> setText(OpenedDirectory);

    ui.PushButtonNext -> setEnable();
}

Problem here is, that I just want to set the PushButtonNext enabled if the QFileDialog was used to create or open a directory. At the moment the PushButtonNext is also enabled when just closing the FileDialog. So I thought of using an emitted signal if possible. Any suggestions?

Was it helpful?

Solution

QFileDialog inherits the accepted signal from QDialog - however, since you're using the static function QFileDialog::getExistingDirectory, you won't have a chance to connect a signal.

Instead, simply check the returned QString: if the user clicks "Cancel", the string will be null (empty).

if(!OpenCreatedDirectory.isEmpty()) ui.PushButtonNext -> setEnable();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top