Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] How to get Total and Used Space of a SD Card in Qt Application?
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] How to get Total and Used Space of a SD Card in Qt Application?

Scheduled Pinned Locked Moved General and Desktop
16 Posts 4 Posters 7.8k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Stoned Jesus
    wrote on last edited by
    #5

    My project doesnt allows me to use QStorageInfo. That's why I am looking for alternative solution :) I see a Windows API GetDiskFreeSpaceEx which gives Free Space. Is their similar API to get Used Space???

    [quote author="raven-worx" date="1367919355"]the Qt module you are looking for is called "QtSystems":http://qt.gitorious.org/qt/qtsystems
    Look at the class "QStorageInfo":http://qt.gitorious.org/qt/qtsystems/blobs/master/src/systeminfo/qstorageinfo.h. It provides you with the path, storage type, available disk space, etc.

    Only drawback is, that you will have to compile it yourself since it's not delivered with the official Qt module (I think it will be in the future sometime though)[/quote]

    --
    Thanks & Regards,
    Stoned Jesus

    1 Reply Last reply
    0
    • L Offline
      L Offline
      leon.anavi
      wrote on last edited by
      #6

      [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?

      http://anavi.org/

      1 Reply Last reply
      0
      • S Offline
        S Offline
        Stoned Jesus
        wrote on last edited by
        #7

        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]

        --
        Thanks & Regards,
        Stoned Jesus

        1 Reply Last reply
        0
        • L Offline
          L Offline
          leon.anavi
          wrote on last edited by
          #8

          [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.

          http://anavi.org/

          1 Reply Last reply
          0
          • raven-worxR Offline
            raven-worxR Offline
            raven-worx
            Moderators
            wrote on last edited by
            #9

            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

            --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
            If you have a question please use the forum so others can benefit from the solution in the future

            1 Reply Last reply
            0
            • S Offline
              S Offline
              Stoned Jesus
              wrote on last edited by
              #10

              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]

              --
              Thanks & Regards,
              Stoned Jesus

              1 Reply Last reply
              0
              • L Offline
                L Offline
                leon.anavi
                wrote on last edited by
                #11

                [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.

                http://anavi.org/

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  Stoned Jesus
                  wrote on last edited by
                  #12

                  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]

                  --
                  Thanks & Regards,
                  Stoned Jesus

                  1 Reply Last reply
                  0
                  • L Offline
                    L Offline
                    leon.anavi
                    wrote on last edited by
                    #13

                    [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.

                    http://anavi.org/

                    1 Reply Last reply
                    0
                    • S Offline
                      S Offline
                      Stoned Jesus
                      wrote on last edited by
                      #14

                      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]

                      --
                      Thanks & Regards,
                      Stoned Jesus

                      1 Reply Last reply
                      0
                      • K Offline
                        K Offline
                        KA51O
                        wrote on last edited by
                        #15

                        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;
                        @

                        1 Reply Last reply
                        0
                        • S Offline
                          S Offline
                          Stoned Jesus
                          wrote on last edited by
                          #16

                          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]

                          --
                          Thanks & Regards,
                          Stoned Jesus

                          1 Reply Last reply
                          0

                          • Login

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • Users
                          • Groups
                          • Search
                          • Get Qt Extensions
                          • Unsolved