Qt World Summit: Register Today!


Disable QSlider's valueChanged on keyboard arrow keys



  • How can I disable QSlider's emitting SIGNAL valueChanged on keyboard arrows and mouseWheel scroll. By setting

    ui->horizontalSlider->setFocusPolicy(Qt::NoFocus);
    

    the keyboards arrows keys are not emitting signals.

    How can I do the same for mouse wheel scroll? I don't want to reimplement my custom Slider class from QSlider. Am asking for any work around or api, so that I can disable the keyboard and mouse wheel scroll responding to qslider.

    The main intention is to avoid sending signals on every valueChange. So I have implemented the following and it's working fine

    on_horizontalSlider_sliderReleased()
    on_horizontalSlider_sliderPressed()
    

    based on bool flag updated in these 2 slots,

    on_horizontalSlider_valueChanged(int)
    

    is doing the required operation...like after slider released, value is being added in the required application.

    Request to provide approaches, examples for the work around.


  • Lifetime Qt Champion

    Hi,

    Wouldn't disabling the tracking property do what you want ?



  • Tried..but it didn't help


  • Qt Champions 2017

    EventFilter is the option.



  • @dheerendra Yes..I'll try with EventFilter


Log in to reply