Qt-interest Archive, December 2006
QFileDialog + sorting -> problem
Message 1 in thread
Hello,
In my app I use QFileDialog to show all files in selected directory in
Detail viewmode with sorting enabled by Time:
#include <QtGui>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QFileDialog filedialog;
filedialog.setViewMode( QFileDialog::Detail );
QDir dir;
dir.setCurrent( "c:\\temp" );
dir.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks);
dir.setSorting(QDir::Size | QDir::Reversed
QDir::DirsFirst|QDir::LocaleAware);
filedialog.setDirectory ( dir );
return filedialog.exec();
}
filedialog opens c:\\temp directory but doesn't sort files list...I
checked qfiledialog.h and it appeared that setDirectory( QDir &dir) only
gets directory name from QDir...what about the rest? How can I sort
listview in filedialog according to what I need before it is shown to user?
Regards,
Marcin
--
[ signature omitted ]
Message 2 in thread
Hi,
> filedialog.setDirectory ( dir );
> [...]
> filedialog opens c:\\temp directory but doesn't sort files list...I
> checked qfiledialog.h and it appeared that setDirectory( QDir &dir) only
> gets directory name from QDir...what about the rest? How can I sort
> listview in filedialog according to what I need before it is shown to user?
QFileDialog::setDirectory() only sets the initial dialog path:
http://doc.trolltech.com/4.2/qfiledialog.html#setDirectory
This is maybe not very clear from the documentation, but the dialog does
not use any properties of the QDir argument apart from the path itself:
This is an overloaded member function, provided for convenience.
--
[ signature omitted ]
Message 3 in thread
Dimitri wrote:
> Hi,
>
>> filedialog.setDirectory ( dir );
>> [...]
>> filedialog opens c:\\temp directory but doesn't sort files list...I
>> checked qfiledialog.h and it appeared that setDirectory( QDir &dir)
>> only gets directory name from QDir...what about the rest? How can I
>> sort listview in filedialog according to what I need before it is
>> shown to user?
>
> QFileDialog::setDirectory() only sets the initial dialog path:
> http://doc.trolltech.com/4.2/qfiledialog.html#setDirectory
>
> This is maybe not very clear from the documentation, but the dialog does
> not use any properties of the QDir argument apart from the path itself:
> This is an overloaded member function, provided for convenience.
>
That's right!
But I also got response from support@.... they said that I should rather
use QObject::findChild() on QFileDialog to find QTreeView and then call
sortColumn(). I'm gonna check this right away.
Marcin
> --
> Dimitri
--
[ signature omitted ]