How to nicely “cast” qint64 to int for QProgressBar

前端 未结 2 759
忘了有多久
忘了有多久 2021-01-19 02:58

I\'m playing around with QFtp (yes .. I know) and all works well.

Using code from their own example(s) as a guideline.

http://doc.qt.io/archives/qt-4.7/netwo

相关标签:
2条回答
  • 2021-01-19 03:31

    Set your progress bar to a range of 0-100, and display the percentage of bytes read instead of trying to set the absolute value.

    0 讨论(0)
  • 2021-01-19 03:39

    You can make the progress bar present the progress as a percentage:

    void FtpWindow::updateDataTransferProgress(qint64 readBytes, 
        qint64 totalBytes) 
    {
        progressDialog->setMaximum(100);
        progressDialog->setValue((qint)((readBytes * 100) / totalBytes));
    }
    
    0 讨论(0)
提交回复
热议问题