QFileDialog setFileMode blues

R

Rincewind

Heya,

I am fairly new to Python and even newer to Qt.
The problem is opening a Qt file dialog to select folders only.
QFileDialog has a nice and dandy setFileMode() function just for that.
The only trouble is that I cannot make it work.
Last thing I've tried was something like this:

self.fd = QtGui.QFileDialog()
self.fd.setFileMode(self.fd.FileMode(4))
filename = self.fd.getOpenFileName()

...but it was fruitless.

Any help? Tons of internets in return!
 
P

Phil Thompson

Heya,

I am fairly new to Python and even newer to Qt.
The problem is opening a Qt file dialog to select folders only.
QFileDialog has a nice and dandy setFileMode() function just for that.
The only trouble is that I cannot make it work.
Last thing I've tried was something like this:

self.fd = QtGui.QFileDialog()
self.fd.setFileMode(self.fd.FileMode(4))
filename = self.fd.getOpenFileName()

..but it was fruitless.

Any help? Tons of internets in return!

QFileDialog.getOpenFileName() is a static method that creates its own
QFileDialog internally. It's not using the one you have created and
configured.

Phil
 
R

Rincewind

QFileDialog.getOpenFileName() is a static method that creates its own
QFileDialog internally. It's not using the one you have created and
configured.

Phil

You are awesome, thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top