PDA

View Full Version : Need help on QFileDialog pleasee



jirach_gag
22nd November 2008, 14:08
Hi all, I was creating an application. My application will open a folder and process all of the images in that folder.
I used the method QFileDialog::getExistingDirectory to let the user choose the directory. But when I execute the
program the file dialog look like this

http://www.qtcentre.org/forum/attachment.php?attachmentid=2713&stc=1&d=1227362670

as you can see that nothing appear, there is no directory list to let the user choose. And I don't know why ?
Anybody know why is this happen ???

PS:: I use Qt 4.4.3 with eclipse integration. Earlier in the code I used QFileDialog::getOpenFileName it was successfully open the file dialog. But the QFileDialog::getExistingDirectory does not success.

Here is the code



// This slot is call when user open file.--------------------------------------
void DR_GUI_NEW::screenFile(){

// Get user selected file path
fileName = QFileDialog::getOpenFileName(this, tr("Open image file for screening"),
QDir::currentPath(),
tr("Images (*.bmp *.jpg *.tiff *.png *.tif)"));

// filename is not empty
if (!fileName.isEmpty()) {

image.load(fileName);
// Load input image
if (image.isNull()) {
QMessageBox::information(this, tr("Diabetic Retinopathy"), tr("Cannot load \"%1\"").arg(fileName));
return ;
}
ui.radioButton_IP_1->setEnabled(true);

// Show input Image
ui.mainImageLabel->setPixmap(QPixmap::fromImage(image));

// Enable Processing Algorithms
ui.actionOld_Algorithms->setEnabled(true);
ui.actionNew_Algorithm->setEnabled(true);

}
//file name is empty
else{
// If filename is empty
// Only empty when user press cancel
// No need to catch error Here ??
}

}// end screenFile slot



// screenDirectory slot -------------------------------------------------------
void DR_GUI_NEW::screenDirectory(){
QMessageBox::information(this, tr("Directory Mode"), tr("Welcom to Directory Mode"));

dirPath = QFileDialog::getExistingDirectory(this,
tr("Please select directory to screen"),
QDir::currentPath(),
QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
}
//-----------------------------------------------------------------------------