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. Displaying available storage with QStorageInfo class
Forum Updated to NodeBB v4.3 + New Features

Displaying available storage with QStorageInfo class

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 267 Views
  • 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.
  • M Offline
    M Offline
    Malikov
    wrote on last edited by
    #1

    I have an issue where I'm trying to get the free memory storage left after creating video .avi file and display it on a GUI. I'm currently using the attached method.
    After a video is created, neither bytesFree and bytesAvailable update either in debug or in the GUI; only once i reboot the computer and open the program again does it show an updated number. How do I change it so that it reflects an updated number after each recording?

        QStorageInfo storage = QStorageInfo::root();
        qint64 availableStorage_qint64 = storage.bytesFree(); //bytesFree(); bytesAvailable
        float availableStorage_float = availableStorage_qint64/(1000.0 * 1000.0 * 1000.0);
        QString availableStorageStr = " " + QString::number(availableStorage_float, 'f', 3) + "GB Available"; // actual displayed string
        ui->labelAvailableMemory->setStyleSheet("background-color: red");
        ui->labelAvailableMemory->setText(availableStorageStr);
    
    1 Reply Last reply
    0
    • B Offline
      B Offline
      Bonnie
      wrote on last edited by
      #2

      QStorageInfo always caches the retrieved information, but you can call refresh() to invalidate the cache.

      1 Reply Last reply
      3
      • M Offline
        M Offline
        Malikov
        wrote on last edited by
        #3

        tnx it worked

        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