Guest User

Convert Milliseconds to minutes and seconds

a guest
Apr 25th, 2014
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. QString MainWindow::getLengthCurrentMedia(qint64 current){
  2.     QString sCurrent = "";
  3.     QString sMinutes = "";
  4.     QString sSeconds = "";
  5.     current = current / 1000;
  6.     int minutes = 0;
  7.     int seconds = 0;
  8.     minutes = current / 60;
  9.     seconds = current % 60;
  10.    
  11.     if(minutes > 9){
  12.         sMinutes = QString::number(minutes);
  13.     }else{
  14.         sMinutes = "0"+QString::number(minutes);
  15.     }
  16.  
  17.     if(seconds > 9){
  18.         sSeconds = QString::number(seconds);
  19.     }else{
  20.         sSeconds = "0"+QString::number(seconds);
  21.     }
  22.  
  23.     sCurrent = sMinutes +":"+sSeconds;
  24.     return sCurrent;
  25.     //QMediaPlayer *player = new QMediaPlayer();
  26.     //i used this function => getLengthCurrentMedia(player->duration());
  27. }
Advertisement
Add Comment
Please, Sign In to add comment