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. Clicking on the background of a ScrollView?

Clicking on the background of a ScrollView?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
qmlscrollviewinteraction
1 Posts 1 Posters 932 Views
  • 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.
  • U Offline
    U Offline
    uchian
    wrote on 24 Apr 2019, 16:15 last edited by
    #1

    Hi,

    I have a QML ScrollView, with a flickable area inside of it that has a single Item inside of it. That item manages it's own size - so there is often an area of the background visible on screen.

    In my full code, the item itself has other Rectangles and MouseAreas as children, and they all work fine, I can click them, drag them, etc.

    I want to be able to perform an action when I click on the background of the scroll view, but I cannot make that work.

    The following is a simple example is what I am trying to do. The red rectangle is the flickable item, the background is a green rectangle. The mouse area on the red rectangle works, but I cannot click the green rectangle.

    Am I missing something obvious here?

    I have tried a number of combinations of preventStealing, propagateComposedEvents.

    import QtQuick 2.0
    import QtQuick.Controls 2.3
    
    Item {
    	ScrollView {
    		anchors.fill: parent
    		ScrollBar.horizontal.policy: ScrollBar.AsNeeded
       		ScrollBar.vertical.policy: ScrollBar.AsNeeded
    
       		background: Rectangle {
       			color: "#00FF00"
       			MouseArea {
    				anchors.fill: parent
    				preventStealing: true
    				onClicked: {
    					console.debug("Clicked background!");
    				}
      			}
    		}
    
    		Flickable {
    			clip: true
    
    			Rectangle {
    				color: "#FF0000"
    				width: 5000
    				height: 200
    
    				MouseArea {
    					anchors.fill: parent
    					onClicked: {
    						console.debug("Clicked Red!");
    					}
    				}
    			}
    		}
    	}
    }
    
    1 Reply Last reply
    0

    1/1

    24 Apr 2019, 16:15

    • Login

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