This is in reference to http://stackoverflow.com/questions/12169878/limit-directory-traversal-in-qfiledialog
I tried ololoepepe's code. It compiled, first time, with no issues. The problem I'm having is getting it to work for me. Here's what I did:
... FileDialog *myFD = new FileDialog(this); ... myFD->setTopDir(dir); QString dirName = myFD->getExistingDirectory(this, "Title", dir); ...
I used cout to show what's being called, and it seems logical. The only problem is, no matter what I do, nothing changes in the dialog. I've even hard-coded things like:
to no avail. What am I missing? I tried to look at her example, but that link is obsolete.
What I really want to do is have a directory list that is completely non-traversable. Perhaps there's an easier way to do this?
getExisitingDirectory is a static function so all the setup you do before is not applied at all. You have to set it up correctly and then call exec on it.
Great! Thanks! Might you have a simple example? I'm fairly new to Qt.
QFileDialog's documentation contains a step by step example
That did the trick. Thanks again.
You're welcome !
Since you have it working now, please mark the thread as solved using the "Topic Tool" button so that other forum users may know a solution has been found :)
Also, while browsing the forum consider up-voting answers that helped you, that will make them easier to find for other users :)
I can disable "lookInCombo" and "sidebar" but not the buttons to the right of "lookInCombo" unless I select a directory and use the currentChanged signal. Is there a signal for when the QFileDialog pops up? Is there a method to select the first item in the list (by index, not by name)? Any other ideas?
Also, I would like to either disable double-click in the directory list or reassign it to choose the directory instead of displaying the set of files beneath that directory. How would I go about getting this done?
With all the modifications you are doing, why not make a complete custom dialog ?
That's a good idea, and I was thinking along those lines. However, is it better to inherit from QDialog or QFileDialog? It seems I'm 90% there using QFileDialog as my baseline. Right now I'm just experimenting, but I plan to incorporate it all into a custom dialog.
Out of curiosity, are child names like "lookInCombo" and "sidebar" documented anywhere, or do you have to search through the Qt code? If so, where's the best place to find the code? It seems like if I knew the child name of what ever houses the buttons to the left of "looksInCombo" (something like "buttonBox"?) I could just disable that and I'm only left with the double-click issue. However, I'm new to customizing Qt, so any suggestions would be greatly appreciated.
You can also take a look at QFileDialog's non-native implementation for either starter or ideas.
No they are not documented because those are implementation details that can change at any time.
I got it all working. I modified ololoepepe's class (http://stackoverflow.com/questions/12169878/limit-directory-traversal-in-qfiledialog) a bit for my pourposes and set the double click interval to 0 (essentially disabling double clicks). Thanks again.