Read the documentation very carefully here. getOpenFileName() is a static method that creates a native file dialog on platforms like Windows and OSX.
When you subclass QFileDialog, you are subclassing the Qt QFileDialog, not the native one. Calling static methods like getOpenFileName() will have no other effect then showing the native dialog becasue they are static, they will not operate on your instance.
In fact:
file = myFd.getOpenFileName(dir,
"All Files (*.jpg; *.png; *.pcx)",
this,
"open file dialog",
tr("Choose a texture"));
file = myFd.getOpenFileName(dir,
"All Files (*.jpg; *.png; *.pcx)",
this,
"open file dialog",
tr("Choose a texture"));
To copy to clipboard, switch view to plain text mode
Is valid code, but is meaningless, it should be:
"All Files (*.jpg; *.png; *.pcx)",
this,
"open file dialog",
tr("Choose a texture"));
file = QFileDialog::getOpenFileName(dir,
"All Files (*.jpg; *.png; *.pcx)",
this,
"open file dialog",
tr("Choose a texture"));
To copy to clipboard, switch view to plain text mode
Therefore, you must use show() or exec() to show your instance of a filedialog. I recomend exec() - that way, when the dialog has been closed, functions like selectedFiles(), selectedFilter(), etc. will return the correct value.
Bookmarks