PDA

View Full Version : Compile QFileDialog.h



Qt Coder
17th August 2009, 13:36
I need to customize QFileDilaog for my application.

(need to disable its "Navigation" functions and "create folder" function)

I had subclassed it and thought I would disable these slots
like this.....


dialog->removeAction(QAction::setDisabled (true) [_q_navigateBackward]);


But all the slots are defined as "Private" so not accessible through object of my derived class.


So I changed specifier from "private" to "public" in "D:\Qt\4.4.3\src\gui\dialogs\qfiledialog.h" ,so that I can access it in derived class.

I need to know now ,how to compile this qfiledialog.h file so that my changes would be in effect.

or is there any alternavite way to acheive this??

faldzip
17th August 2009, 14:38
First of all I don't understand this code:

dialog->removeAction(QAction::setDisabled (true) [_q_navigateBackward]);

And second of all, as I remember from another topic you want to let the user choose the file from some directory, which directory cannot be changed? I think that it would be much easier to just show the some dialog containing some list view (or tree view to have more columns) with files from that directory, and allow user to choose one row and press OK.
You can get files with QDir::entryList().

Qt Coder
18th August 2009, 08:06
I m like newbie in this Qt world..


Would anyone tell me how to use simple dialog (instead off QFiledialog) to show diretory files in it...

yogeshgokul
18th August 2009, 10:58
Would anyone tell me how to use simple dialog (instead off QFiledialog) to show diretory files in it...
Use:
QDirModel

QTreeView

Qt Coder
18th August 2009, 14:48
I have implemented QInputDialog to select images


AppPath = QApplication::applicationDirPath();
AppPath.append("/Images");

QDir dir = QDir(AppPath);
dir.setFilter( QDir::Files | QDir::Hidden | QDir::NoSymLinks );
dir.setSorting( QDir::Name);
dir.setNameFilters(filters);

QStringList filenames = dir.entryList(filters,QDir::Files, QDir::Name);

filepath = QInputDialog::getItem(NULL, tr("Select Image"),
"", filenames, 0, false, &ok);


Now my problem is,even if I click open/cancel /close its returning me the filename selected in combo box.

Is there any way to differentiate between accepted and rejected signal of QInputDialog?

yogeshgokul
18th August 2009, 15:09
Is there any way to differentiate between accepted and rejected signal of QInputDialog?

Check this:

int returnCode;
returnCode = fileDialog->exec();
if(returnCode == QDialog::Accepted)
do something.
if(returnCode == QDialog::Rejected)
do something else.

Qt Coder
18th August 2009, 15:18
Its giving me error creating object of QInputDialog.


../../../include/QtGui/../../src/gui/dialogs/qinputdialog.h:70:
QInputDialog::~QInputDialog()' is private


So I m using


filepath = QInputDialog::getItem(NULL, tr("Select Image"),
"", filenames, 0, false, &ok);

but to call


fileDialog->exec();

I will have to instantiate QInputDialog........


How to?

nightghost
18th August 2009, 15:47
Didnt you read the manual?: http://doc.trolltech.com/4.5/qinputdialog.html#getItem


If ok is nonnull *a ok will be set to true if the user pressed OK and to false if the user pressed Cancel