Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QSlider::handle of QMediaPlayer pull back

QSlider::handle of QMediaPlayer pull back

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 593 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • sonichyS Offline
    sonichyS Offline
    sonichy
    wrote on last edited by
    #1

    If I do not drag the handle of slider quickly, the handle will pull back.
    It seems I have to disconnet QMediaPlayer::positionChanged(qint64) when drag, and connect again when sliderReleased().

    player = new QMediaPlayer;
    connect(player,SIGNAL(positionChanged(qint64)),this,SLOT(positionChange(qint64)));
    connect(ui->sliderProgress,SIGNAL(sliderReleased()),this,SLOT(setMPPosition()));
    void MainWindow::positionChange(qint64 p)
    {    
        ui->sliderProgress->setValue(p);    
    }
    void MainWindow::setMPPosition()
    {
        player->setPosition(ui->sliderProgress->value());
    }
    

    https://github.com/sonichy

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      You can react on the sliderPressed signal and disable the update of the slider using a boolean variable.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • sonichyS Offline
        sonichyS Offline
        sonichy
        wrote on last edited by sonichy
        #3

        So simple !

        void MainWindow::positionChange(qint64 p)
        {
            if(!ui->sliderProgress->isSliderDown()) ui->sliderProgress->setValue(p);
        }
        

        https://github.com/sonichy

        1 Reply Last reply
        1

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved