Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. How to stack MouseArea objects?
Forum Updated to NodeBB v4.3 + New Features

How to stack MouseArea objects?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 215 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.
  • P Offline
    P Offline
    pderocco
    wrote on last edited by
    #1

    MouseArea seems to be full of perverse design decisions. I have a TabView and I'd like to enhance it, specifically by making a pressAndHold on a tab close it.

    If I attach a MouseArea to the Rectangle I use for the tab, and give it an onPressAndHold handler, tabs no longer work. The docs suggest that setting the propagateComposedEvents property, and clearing mouse.accepted, might help, but it doesn't. It appears that, while this might do what it literally says, the mere presence of onPressAndHold prevents non-composed events, like pressed and released from getting through to the underlying tab's built-in MouseArea. How useful.

    So I thought I might just build my own pressAndHold handler out of a Timer and a pair of onPressed and onReleased handlers, starting the timer in the former and stopping it in the latter, and having the onTriggered handler close the tab. Not surprisingly, this prevents the tabs from working, because the pressed signal is swallowed by my own handler. So I clear mouse.accepted in my handler, which makes tabs work again. But now my onReleased handler never gets called, because the MouseArea logic assumes that if I cleared mouse.accepted in my onPressed handler, it must mean that I ignored the press, and couldn't possibly have any interest in the release. Brilliant design choice.

    So what do I do? At every step of the way, MouseArea is fighting against me. How do I add processing to mouse events without interfering with other objects that want to listen to the same events?

    1 Reply Last reply
    0

    • Login

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