[Qt-interest] restricting navigation in filedialog

Alexis Ménard alexis.menard at trolltech.com
Wed Apr 15 10:01:51 CEST 2009


On Wednesday 15 April 2009 07:04:51 sathya tej wrote:
> I am using linux (ubuntu 8.04) Qt 4.3.4
>
> QFileDialog *fd = new QFileDialog(this);
>
> connect(fd,SIGNAL(directoryEntered ( const QString &  ) ), this,SLOT(dirs(
> const QString &)));
>

With 4.3.4 it pick the Qt file dialog. I fully encourage you to upgrade your 
Qt to at least 4.4 because in this version the QFileDialog received a brand 
new data model that is easier to use and much more efficient.

And the solution to solve your problem is to install a QSortFilterProxyModel 
on the QFileDialog (call model() to get the source model). You can then filter 
in the proxy all nodes (directories) you don't want. You can check the doc of 
QSortFilterProxyModel and you can set it on the dialog by calling 
setProxyModel. I fixed some bugs with that particular use case, therefor i 
encourage you to upgrade to 4.5.0 or 4.5.1 when it will be release.

>
>
> On Wed, Apr 15, 2009 at 10:28 AM, Scott Aron Bloom
> <Scott.Bloom at sabgroup.com
>
> > wrote:
> >
> >  Show the code you are using for the creation of the dialog as well as
> > the connection… and what OS since if you are on windows, the statics use
> > the native dialogs by default which don’t do the call backs…
> >
> >
> >
> > You may need to set it to use the non-native dialogs
> >
> >
> >
> > Scott
> >
> >
> >
> > *From:* qt-interest-bounces at trolltech.com [mailto:
> > qt-interest-bounces at trolltech.com] *On Behalf Of *sathya tej
> > *Sent:* Tuesday, April 14, 2009 9:32 PM
> > *To:* qt-interest at trolltech.com
> > *Subject:* [Qt-interest] restricting navigation in filedialog
> >
> >
> >
> > hello all,
> >
> > I need to restrict the user to view only the contents of a sd card. He
> > should not be able to view directories outside the sd card.
> >
> > I have tried using  the signal,
> >
> > void QFileDialog::directoryEntered ( const QString & );
> >
> > using which i could determine if its allowed path or not.
> >
> > But when i connect this signal to a slot it isnt entering the slot.
> >
> > I need some guidance on this matter.
> >
> > Please suggest me a better alternative to tackle this problem.
> >
> >
> > Thank You,
> >
> > Sathya.
> >
> >
> > --
> > whatever happens happens for GOOD

-- 

Alexis Ménard
Software Engineer, Widgets Team 1
Qt Software, Nokia Norge AS, Sandakerveien 116, 0484 Oslo, Norway
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090415/2edbaf3e/attachment.html 


More information about the Qt-interest-old mailing list