[SOLVED] How to get Total and Used Space of a SD Card in Qt Application?
-
QtMobility is not delivered with Qt's official module thats why we have been told to avoid it :(
[quote author="leon.anavi" date="1367919568"]
[quote author="Stoned Jesus" date="1367919469"]My project doesnt allows me to use QStorageInfo. That's why I am looking for alternative solution :)
[/quote]Please excuse my curiosity but why are you searching for another API if QSystemStorageInfo is working fine and why you cannot use it in your project?[/quote]
-
[quote author="Stoned Jesus" date="1367919731"]QtMobility is not delivered with Qt's official module thats why we have been told to avoid it :(
[/quote]
Yes, you should use Qt System Info module if you are using Qt 5. But if you are using 4.8 it is OK to include Qt Mobility.
-
QStrorageInfo uses GetDiskFreeSpaceEx internally btw.
if you are only allowed to use "standard" Qt libraries you won't be able to implement what you want
-
I am using Qt 4.8. Unfortunately I cant use Qtmobility.... Oh!! I hate these restrictions :(
[quote author="leon.anavi" date="1367919874"]
[quote author="Stoned Jesus" date="1367919731"]QtMobility is not delivered with Qt's official module thats why we have been told to avoid it :([/quote]
Yes, you should use Qt System Info module if you are using Qt 5. But if you are using 4.8 it is OK to include Qt Mobility.[/quote]
-
[quote author="raven-worx" date="1367919914"]# QStrorageInfo uses GetDiskFreeSpaceEx internally btw.[/quote]
Methods availableDiskSpace and totalDiskSpace are public so the total free space can be calculated very easily.
-
Thanks Raven.
[quote author="leon.anavi" date="1367920058"]
[quote author="raven-worx" date="1367919914"]# QStrorageInfo uses GetDiskFreeSpaceEx internally btw.[/quote]Methods availableDiskSpace and totalDiskSpace are public so the total free space can be calculated very easily.[/quote]
-
[quote author="Stoned Jesus" date="1367919731"]QtMobility is not delivered with Qt's official module thats why we have been told to avoid it :(
[/quote]OK, if you want to use Qt 4.8 and you don't want to use Qt Mobility then you have to implement your own solution using the specific API of the platform that you are targeting. Qt does not provide other APIs for this task.
-
Yes I will get into that and post the answer here :)
[quote author="leon.anavi" date="1367920547"]
[quote author="Stoned Jesus" date="1367919731"]QtMobility is not delivered with Qt's official module thats why we have been told to avoid it :(
[/quote]OK, if you want to use Qt 4.8 and you don't want to use Qt Mobility then you have to implement your own solution using the specific API of the platform that you are targeting. Qt does not provide other APIs for this task.[/quote]
-
In case you're allowed to use boost, there's "boost::filesystem":http://www.boost.org/doc/libs/1_53_0/libs/filesystem/doc/index.htm .
@
boost::filesystem::path p (filepath);
boost::filesystem::space_info s = boost::filesystem::space(p);
quint64 uFreeStorage = s.available;
quint64 uTotalStorage = s.capacity;
@ -
Wow this worked :) thanks
[quote author="KA51O" date="1367922920"]In case you're allowed to use boost, there's "boost::filesystem":http://www.boost.org/doc/libs/1_53_0/libs/filesystem/doc/index.htm .
@
boost::filesystem::path p (filepath);
boost::filesystem::space_info s = boost::filesystem::space(p);
quint64 uFreeStorage = s.available;
quint64 uTotalStorage = s.capacity;
@[/quote]