Qt-jambi-interest Archive, January 2007
hybrid file dialog
Message 1 in thread
hi,
does anyone know if there is implemented any dialog that lets the user
to choose either a couple of files or a directory?
I'm developing a little audio player and it would be nice if the user
could select just certain files or a whole directory in order to play
all its files.
I know that some gtk applications have this feature but probably it
isn't too standard at all...
thanks in advance
--
[ signature omitted ]
Message 2 in thread
Borja Martín wrote:
> hi,
> does anyone know if there is implemented any dialog that lets the user
> to choose either a couple of files or a directory?
> I'm developing a little audio player and it would be nice if the user
> could select just certain files or a whole directory in order to play
> all its files.
> I know that some gtk applications have this feature but probably it
> isn't too standard at all...
Hi,
By using QFileDialog you can either select a single directory by calling
QFileDialog::getExistingDirectory() or select a files, filtered on
filename using QFileDialog::getOpenFileNames. There is no way to select
both directories and/or files from the same functioncall.
An alternate way of doing this is to use a QLineEdit with a completer
that shows only directories and the files you pick out, (say mp3-files):
List<String> nameFilters = new ArrayList<String>();
nameFilters.add("*.mp3");
QDirModel dirModel = new QDirModel(this);
dirModel.setNameFilters(nameFilters);
dirModel.setFilter(new QDir.Filters(QDir.Filter.AllDirs,
QDir.Filter.Files));
QCompleter completer = new QCompleter(this);
completer.setModel(dirModel);
completer.setCaseSensitivity(Qt.CaseSensitivity.CaseInsensitive);
QLineEdit path = new QLineEdit();
path.setCompleter(completer);
---
best regards,
Gunnar