Important: Please read the Qt Code of Conduct -

Converting Middle Click to Left Click

  • My application is desktop, not mobile. This kind of behavior is possible with widgets and the QGraphicsScene but I was really hoping to use QML for this.

    From my search of these forums, I'm seeing this may be an open issue that is long standing but I'm hoping someone has an elegant solution using only QML. I have a lot of experience with C++/QML interop but I was really hoping to avoid anything but pure QML to achieve this.

    I am using a flickable surface. I want to be able to place items on this surface and to move them around. It's going to be a large area (much of it will be off screen at any one time) that can be flicked through by pressing and holding the middle mouse button and flicking, zoomed in and out (two dimensions), and used to select and manipulate items (drag them around).

    Flickable takes mouse press events and responds to them. I can only think of a few ways to achieve what I want. I can try to subclass Flickable and override the event handlers, but I wanted to avoid it.

    The way that I would prefer to do it, even though it seems hackish to me as well, would be to put a mouseArea over the flickable, detect a middle press and translate that to a left press (Flickable seems only to "flick" on left press).

    The ideal way would be to have a handler defined in QML that detected presses and be able to translate the event right there. That seems like a pipe dream, though.

    Can anyone make a suggestion? Thanks.

Log in to reply