Hello,
I'm trying to get the root drive from my application. I'm using Windows 7 and I have 2 drives (C:\ and D:\). The drive C:\ is where my OS is installed and the drive D:\ is where my application is running.
This is a piece of code from my application:
dir.setPath (m_app_dir);
QString m_app_dir = "D:/slave";
QDir dir;
dir.setPath (m_app_dir);
To copy to clipboard, switch view to plain text mode
QString r = dir.root ().path ();
To copy to clipboard, switch view to plain text mode
or
QString r
= dir.
root ().
absolutePath ();
QString r = dir.root ().absolutePath ();
To copy to clipboard, switch view to plain text mode
Both codes return C:\, is that the expected result?
If so, what would return D:\?
From Qt docs about root (): http://qt-project.org/doc/qt-5/qdir.html#root
Returns the root directory.
The directory is constructed using the absolute path of the root directory, ensuring that its path() will be the same as its absolutePath().
So I was assuming D:\ would be the return of the root() method.
Thanks,
Renan
Bookmarks