HelloDan
4th March 2009, 15:26
FileFilter::FileFilter(QWidget *parent):QDialog(parent)
{
setupUi(this);
// Disable relative buttons
loadButton->setEnabled(false);
buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
//connect signals and slots
connect(browseButton,SIGNAL(clicked()),this,SLOT(b rowse()));
connect(selectButton,SIGNAL(clicked()),this,SLOT(s elect()));
// connect(loadButton,SIGNAL(clicked()),this,SLOT(loa d()));
// connect(buttonBox->button(QDialogButtonBox::Ok),SIGNAL(clicked()),thi s,SLOT(deleteInDir()));
connect(fileTypeComboBox,SIGNAL(currentIndexChange d(int index)), this, SLOT(textChanged()));
connect(deletedDirComboBox,SIGNAL(currentIndexChan ged(int index)), this, SLOT(textChanged()));
connect(sourceDirComboBox,SIGNAL(currentIndexChang ed(int index)), this, SLOT(textChanged()));
}
// if all the file input directory have been configured, enable OK and button.
void FileFilter::textChanged()
{
buttonBox->button(QDialogButtonBox::Ok)->setEnabled((!(sourceDirComboBox->currentText()).isEmpty())&&(!(deletedDirComboBox->currentText()).isEmpty())&&(!(fileTypeComboBox->currentText()).isEmpty()));
loadButton->setEnabled((!(sourceDirComboBox->currentText()).isEmpty())&&(!(deletedDirComboBox->currentText()).isEmpty())&&(!(fileTypeComboBox->currentText()).isEmpty()));
}
void FileFilter::browse()
{
QString directory = QFileDialog::getExistingDirectory(this,
tr("Select a directory"), QDir::currentPath());
if (!directory.isEmpty())
{
sourceDirComboBox->addItem(QDir::toNativeSeparators(directory));
sourceDirComboBox->setCurrentIndex(sourceDirComboBox->count() - 1);
}
}
// select a dir to delete files from it
void FileFilter::select()
{
QString directory = QFileDialog::getExistingDirectory(this,
tr("Select directory"), QDir::currentPath());
if (!directory.isEmpty())
{
deletedDirComboBox->addItem(QDir::toNativeSeparators(directory));
deletedDirComboBox->setCurrentIndex(deletedDirComboBox->count() - 1);
}
}
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!
{
setupUi(this);
// Disable relative buttons
loadButton->setEnabled(false);
buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
//connect signals and slots
connect(browseButton,SIGNAL(clicked()),this,SLOT(b rowse()));
connect(selectButton,SIGNAL(clicked()),this,SLOT(s elect()));
// connect(loadButton,SIGNAL(clicked()),this,SLOT(loa d()));
// connect(buttonBox->button(QDialogButtonBox::Ok),SIGNAL(clicked()),thi s,SLOT(deleteInDir()));
connect(fileTypeComboBox,SIGNAL(currentIndexChange d(int index)), this, SLOT(textChanged()));
connect(deletedDirComboBox,SIGNAL(currentIndexChan ged(int index)), this, SLOT(textChanged()));
connect(sourceDirComboBox,SIGNAL(currentIndexChang ed(int index)), this, SLOT(textChanged()));
}
// if all the file input directory have been configured, enable OK and button.
void FileFilter::textChanged()
{
buttonBox->button(QDialogButtonBox::Ok)->setEnabled((!(sourceDirComboBox->currentText()).isEmpty())&&(!(deletedDirComboBox->currentText()).isEmpty())&&(!(fileTypeComboBox->currentText()).isEmpty()));
loadButton->setEnabled((!(sourceDirComboBox->currentText()).isEmpty())&&(!(deletedDirComboBox->currentText()).isEmpty())&&(!(fileTypeComboBox->currentText()).isEmpty()));
}
void FileFilter::browse()
{
QString directory = QFileDialog::getExistingDirectory(this,
tr("Select a directory"), QDir::currentPath());
if (!directory.isEmpty())
{
sourceDirComboBox->addItem(QDir::toNativeSeparators(directory));
sourceDirComboBox->setCurrentIndex(sourceDirComboBox->count() - 1);
}
}
// select a dir to delete files from it
void FileFilter::select()
{
QString directory = QFileDialog::getExistingDirectory(this,
tr("Select directory"), QDir::currentPath());
if (!directory.isEmpty())
{
deletedDirComboBox->addItem(QDir::toNativeSeparators(directory));
deletedDirComboBox->setCurrentIndex(deletedDirComboBox->count() - 1);
}
}
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!