qtqmlqtquick2

Deactivate QML Item to avoid overlapping of action areas


How to proceed if one has stacked elements with stacked action areas to make sure that you acton what you see and not on underlying elements?

I'm following a tutorial on Qt Quick 2.0 programming for desktop, where one makes a post-it like application with several pages to switch on.

In the main.qml, I have a PagePanel.qml, where one have 3 Page.qml one on top of the other. Each one has opacity 0.0 until opacity 1.0 is forced by clicking a corresponding marker, to visualize the selected page. In the page are linked (and created) Items Note.qml that are sticker-notes with an area for dragging the item around and an area for writing on top.

Problem is that if I have on different pages two notes overlapping, if I try to drag or to write on a note there can be that I'm actually (without seeing it) dragging and writing on the underlying note.

In other words, the action regions of the different pages remain active when switching from a page to the other.

How can one make inactive the hidden pages and act only on the visualized one?


Solution

  • If you have 3 Page elements on top of each other. The easiest would be to set visible: false to the one you want to disable and visible: true to the active one. This will disable all the MouseArea and DropArea in the elements that are not visible.