大家。我正在用 qt5 重写我的 qt4 音乐播放器。而且我无法制作正确的搜索滑块,就像在声子中一样。你有一个简单的例子来实现这部分 UI 吗?
UPD:这是我的方法:
//mainwindow.cpp
connect(ui->seekSlider,SIGNAL(sliderMoved(int)),music,SLOT(setPosition(int)));
connect(music,SIGNAL(newPosition(qint64)),this,SLOT(positionChanged(qint64)));
connect(music,SIGNAL(newRange(qint64)),this,SLOT(durationChanged(qint64)));
void MainWindow::positionChanged(qint64 position)
{
ui->seekSlider->setValue(position);
}
void MainWindow::durationChanged(qint64 duration)
{
ui->seekSlider->setRange(0,duration);
}
//music class realization
player = new QMediaPlayer;
connect(player,SIGNAL(positionChanged(qint64)),this,SIGNAL(newPosition(qint64)));
connect(player,SIGNAL(durationChanged(qint64)),this,SIGNAL(newRange(qint64)));
void MusicControl::setPosition(int position)
{
player->setPosition(position);
}