Advertisement
Guest User

Untitled

a guest
Apr 29th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. QString size_human ( float size )
  2. {
  3. float num = size;
  4. QStringList list;
  5. list << "KB" << "MB" << "GB" << "TB";
  6. QStringListIterator i ( list );
  7. QString unit ( "bytes" );
  8. while ( num >= 1024.0 && i.hasNext() )
  9. {
  10. unit = i.next();
  11. num /= 1024.0;
  12. }
  13. return QString().setNum ( num, 'f', 2 ) + " " + unit;
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement