set enable QPushButton doesn't work.
Code:
{
setupUi(this);
// Disable relative buttons
loadButton->setEnabled(false);
//connect signals and slots
connect(browseButton,SIGNAL(clicked()),this,SLOT(browse()));
connect(selectButton,SIGNAL(clicked()),this,SLOT(select()));
// connect(loadButton,SIGNAL(clicked()),this,SLOT(load()));
// connect(buttonBox->button(QDialogButtonBox::Ok),SIGNAL(clicked()),this,SLOT(deleteInDir()));
connect(fileTypeComboBox,SIGNAL(currentIndexChanged(int index)), this, SLOT(textChanged()));
connect(deletedDirComboBox,SIGNAL(currentIndexChanged(int index)), this, SLOT(textChanged()));
connect(sourceDirComboBox,SIGNAL(currentIndexChanged(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()
{
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()
{
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!
Re: set enable QPushButton doesn't work.
I also tried void QComboBox::editTextChanged ( const QString & text ) [signal] instead of currentIndexChanged(int index), but failed too.
Re: set enable QPushButton doesn't work.
I come to know that, the complier tell me.
No such signal QComboBox::currentIndexChanged(int index) in filefilter.cpp:22
But that does have a QComboBox::currentIndexChanged(int index) signal. Why?
By the way, the following segment code is just copy from the demo
Code:
for(int i = 0; i < files.size(); ++i)
{
QFile file(currentDir.
absoluteFilePath(files
[i
]));
fileNameItem->setFlags(fileNameItem->flags() ^ Qt::ItemIsEditable);
.arg(int((size + 1023) / 1024)));
sizeItem->setTextAlignment(Qt::AlignRight | Qt::AlignVCenter);
sizeItem->setFlags(sizeItem->flags() ^ Qt::ItemIsEditable);
int row = filesTable->rowCount();
filesTable->insertRow(row);
filesTable->setItem(row, 0, fileNameItem);
filesTable->setItem(row, 1, sizeItem);
}
But why the size show in cells are 0. The files are MP3, Their sizes are not zero.
Re: set enable QPushButton doesn't work.
You are not supposed to give name of data type in connect..
ie.
Quote:
connect(fileTypeComboBox,SIGNAL(currentIndexChange d(int index)), this, SLOT(textChanged()));
should be
Quote:
connect(fileTypeComboBox,SIGNAL(currentIndexChange d(int)), this, SLOT(textChanged()));
Re: set enable QPushButton doesn't work.
Quote:
Originally Posted by
aamer4yu
You are not supposed to give name of data type in connect..
ie.
should be
What about the zero file size? I copy the code from the demo
Re: set enable QPushButton doesn't work.
the problem had been solved.
QDir currentDir = QDir(sourcePath); I make it a local variable.
Thanks for you attention!