Important: Please read the Qt Code of Conduct -

Change pressAndHold Timeout

  • Hi,

    i use the MouseAreas pressAndHold signal alot for drag and drop purposes.
    The docs say that the timerout is currently set to 800 ms. But i couldn't find a way to
    change the time after that the signal is emitted.

    Is there a way to change that ?

    Because if you have a lot of drag and drop going on the timeout seems a bit anoying.

    Thanks guys.

  • You implement drag and drop by your own? Why you don't use drag property? Or is there also a timeout to start the drag?

  • I had to implement it by my own because of my application structure.
    I couldn't just drag an object around because I had to drop it to completely different object structures. Thats why i instantiate dedicated drag objects.

    Its a bit tricky to explain.

    So I used the pressAndHold signal to create a new draggable object.

  • Hmmm, ok and what if you implement this also by your own? With pressed signal start a timer, with released stop it. And if the timer has a value that you like, send your own signal?

  • ok that is one way to do it. so if there is no way to just change the timeout i could go to every part for the drag and drop handling and do it all by hand.

  • Lifetime Qt Champion


    From a quick look at the source code, it seems to be a hardcoded value

  • Where i can find the source? Sorry but every time i google for MouseArea only found examples but not the source itself.

  • Moderators

    Seems already requested. Check "this":

  • Moderators

    bq. Where i can find the source?

    If you have source installed, goto <QtDir>/5.3/Src/qtbase/src/gui/kernel/qplatformtheme.cpp and check QPlatformTheme::defaultThemeHint(ThemeHint hint)

  • Thanks SGaist,

    you're right its still hard coded.

    case MousePressAndHoldInterval:
        return QVariant(800);

    It would be nice if we were be to customize these settings in a future release.
    Because they have a huge impact on the user experience.

    To bad that this can't be overwritten.
    Guess i have to wait for a user response to decide whether or not i'm going to implement this all by myself.

    Thanks guys.

Log in to reply