Qt Code:
  1. FileFilter::FileFilter(QWidget *parent):QDialog(parent)
  2. {
  3.  
  4. setupUi(this);
  5. // Disable relative buttons
  6. loadButton->setEnabled(false);
  7. buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
  8.  
  9. //connect signals and slots
  10. connect(browseButton,SIGNAL(clicked()),this,SLOT(browse()));
  11. connect(selectButton,SIGNAL(clicked()),this,SLOT(select()));
  12. // connect(loadButton,SIGNAL(clicked()),this,SLOT(load()));
  13. // connect(buttonBox->button(QDialogButtonBox::Ok),SIGNAL(clicked()),this,SLOT(deleteInDir()));
  14. connect(fileTypeComboBox,SIGNAL(currentIndexChanged(int index)), this, SLOT(textChanged()));
  15. connect(deletedDirComboBox,SIGNAL(currentIndexChanged(int index)), this, SLOT(textChanged()));
  16. connect(sourceDirComboBox,SIGNAL(currentIndexChanged(int index)), this, SLOT(textChanged()));
  17. }
  18.  
  19.  
  20.  
  21. // if all the file input directory have been configured, enable OK and button.
  22. void FileFilter::textChanged()
  23. {
  24. buttonBox->button(QDialogButtonBox::Ok)->setEnabled((!(sourceDirComboBox->currentText()).isEmpty())&&(!(deletedDirComboBox->currentText()).isEmpty())&&(!(fileTypeComboBox->currentText()).isEmpty()));
  25. loadButton->setEnabled((!(sourceDirComboBox->currentText()).isEmpty())&&(!(deletedDirComboBox->currentText()).isEmpty())&&(!(fileTypeComboBox->currentText()).isEmpty()));
  26. }
  27.  
  28.  
  29.  
  30. void FileFilter::browse()
  31. {
  32. QString directory = QFileDialog::getExistingDirectory(this,
  33. tr("Select a directory"), QDir::currentPath());
  34. if (!directory.isEmpty())
  35. {
  36. sourceDirComboBox->addItem(QDir::toNativeSeparators(directory));
  37. sourceDirComboBox->setCurrentIndex(sourceDirComboBox->count() - 1);
  38. }
  39. }
  40.  
  41.  
  42.  
  43.  
  44.  
  45. // select a dir to delete files from it
  46. void FileFilter::select()
  47. {
  48. QString directory = QFileDialog::getExistingDirectory(this,
  49. tr("Select directory"), QDir::currentPath());
  50. if (!directory.isEmpty())
  51. {
  52. deletedDirComboBox->addItem(QDir::toNativeSeparators(directory));
  53. deletedDirComboBox->setCurrentIndex(deletedDirComboBox->count() - 1);
  54. }
  55. }
To copy to clipboard, switch view to plain text mode 

Hi my friends! I'm coming for help again.

In a dialog base app, I use two QFileDialogs to get dirs to store in two comboxs. if the three comboxs are not empty, it will enable the OK and Load buttons, But my code doesen't work. Could you help to find the problem?

Thanks!