How to setRootPath to desktop for QFileSystemModel in Windows?
Hi,
I am trying to set the Root Path of the QFileSystemModel to the desktop on windows 7.
but i don't know how to do this?
i tried QFileSystemModel::setRootPath(QString("")) but did not work.
can any body help?
Thank you
Re: How to setRootPath to desktop for QFileSystemModel in Windows?
hi the following will work
Code:
QFileSystemModel::setRootPath( "c:\\" )
hope it helps
Bala
Re: How to setRootPath to desktop for QFileSystemModel in Windows?
Set the path to whatever QDesktopServices::storageLocation() returns for QDesktopServices::DesktopLocation.
Re: How to setRootPath to desktop for QFileSystemModel in Windows?
I did just as you said but still the application starts from the drivers path (on windows) not the desktop path
http://img843.imageshack.us/img843/8316/desktop0.png
I used the following code
Code:
m_pFileSystemModel = new QFileSystemModel;
m_pFileSystemModel->setRootPath(dir);
ui->treeView->setModel(m_pFileSystemModel);
but i want it to be like this photo
http://img138.imageshack.us/img138/973/desktopsb.png
Re: How to setRootPath to desktop for QFileSystemModel in Windows?
The problem is the second picture does not show the true model of the filesystem.
What does line #2 of your snippet return?
Re: How to setRootPath to desktop for QFileSystemModel in Windows?
the second picture is not Qt application it is a visual basic application and i want to make one like it with Qt.
Line #2 returns "C:\Users\mismael\Desktop"
Re: How to setRootPath to desktop for QFileSystemModel in Windows?
Quote:
Originally Posted by
mismael85
the second picture is not Qt application
I know. What I say is that it is not a model of your file system.
Quote:
Line #2 returns "C:\Users\mismael\Desktop"
And when you set it as the root path of your model it still shows some other directory? Make sure you didn't make any mistakes (e.g. read the root path of the model back to see if it is set to the right location). Note - it will not make the dialog show things such as "libraries", "control panel" and stuff as they are artificial entities that are not part of the file system. If you want the exact same output, use native means to get it.
Re: How to setRootPath to desktop for QFileSystemModel in Windows?
have you done with this?
recently i need my tree to run like the native CMFCShellTreeCtrl either.
if you can mail any tips to my email: seak04#gmail.com will be graceful.