スリーピングはプログラムを1秒間ブロックします。何が起こっているのか(音楽再生、またはあなたのアプリ内で実行中のプロセス)は、基本的には機能しません。
何が起こるかは、プログラムが値を10に設定し、1秒間スリープし(何も起こりません)、20に設定し、再び1秒間プログラムをブロックするということです。基本的に、プログラムは常にブロックされ、毎秒スライダの値が設定されます。
ソリューションは、例えば、進捗値を得ることです:
int total_time, current_time; //Durations in seconds
int progress; //Will hold the progress percentage
//Somehow you get the total song time and the current song timer
//...
progress = (current_time/total_time)*100
this->ui->horizontalSlider->setValue(progress);
または:
/*When initializing the slider*/
int total_time; //Duration in seconds
//Somehow you get the the total song time...
//...
this->ui->horizontalSlider->setRange(0,total_time);
そして、あなたは、イベントを許可しない限り、あなたの日常
/* In the routine where you refresh the slider */
int current_time; //Duration in seconds
//Somehow you get the the current song timer...
//...
this->ui->horizontalSlider->setValue(current_time);
何も起こりませんでループを進めてください。実際に何を達成しようとしていますか? –
スライダーは、1秒ごとにプログレスバーのようにスライドします(秒/ 100の値の長さで)。だから、私は何かを試していた、価値観を見せて、1秒間寝る、次の値を見る、寝る、など。 –
['QTimer'](http://doc.qt.io/qt-5/qtimer.html)を見て、スライダーを更新する関数に' QTimer :: timeout'信号を接続してください。 –