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. ScrollView can't detect custom contentItem without an id.
Forum Updated to NodeBB v4.3 + New Features

ScrollView can't detect custom contentItem without an id.

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
scrollviewflickable
3 Posts 2 Posters 713 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.
  • M Offline
    M Offline
    Moisi
    wrote on 28 Jan 2019, 15:02 last edited by
    #1

    Hi,

    I'm using Qml 2.9.

    I have a simple ScrollView with a custom contentItem (width a custom property) and a Button. When I click on the Button, I expect to display the custom property from the contentItem.

    Here is my code:

    Window
    {
    	visible: true
    	width: 300
    	height: 150
    	title: qsTr("Tests")
    
    	ScrollView
    	{
    		id: scrollView
    		height: 150
    		contentItem: Flickable
    		{
    			property int myTest: 42
    		}
    
    		Button { text: "Click me"; onClicked: console.log(scrollView.contentItem.myTest) }
    	}
    }
    

    When I click on the button, I got the following output : "qml: undefined".

    Now, I add an id to my custom contentItem:

    Window
    {
    	visible: true
    	width: 300
    	height: 150
    	title: qsTr("Tests")
    
    	ScrollView
    	{
    		id: scrollView
    		height: 150
    		contentItem: Flickable
    		{
    			id: myFlickable
    			property int myTest: 42
    		}
    
    		Button { text: "Click me"; onClicked: console.log(scrollView.contentItem.myTest) }
    	}
    }
    

    And now, when I click on the button, I got the expected output: "qml: 42".

    My question is: Why my Flickable is not detected by the ScrollView if I don't put any id ???

    J 1 Reply Last reply 28 Jan 2019, 15:28
    0
    • M Moisi
      28 Jan 2019, 15:02

      Hi,

      I'm using Qml 2.9.

      I have a simple ScrollView with a custom contentItem (width a custom property) and a Button. When I click on the Button, I expect to display the custom property from the contentItem.

      Here is my code:

      Window
      {
      	visible: true
      	width: 300
      	height: 150
      	title: qsTr("Tests")
      
      	ScrollView
      	{
      		id: scrollView
      		height: 150
      		contentItem: Flickable
      		{
      			property int myTest: 42
      		}
      
      		Button { text: "Click me"; onClicked: console.log(scrollView.contentItem.myTest) }
      	}
      }
      

      When I click on the button, I got the following output : "qml: undefined".

      Now, I add an id to my custom contentItem:

      Window
      {
      	visible: true
      	width: 300
      	height: 150
      	title: qsTr("Tests")
      
      	ScrollView
      	{
      		id: scrollView
      		height: 150
      		contentItem: Flickable
      		{
      			id: myFlickable
      			property int myTest: 42
      		}
      
      		Button { text: "Click me"; onClicked: console.log(scrollView.contentItem.myTest) }
      	}
      }
      

      And now, when I click on the button, I got the expected output: "qml: 42".

      My question is: Why my Flickable is not detected by the ScrollView if I don't put any id ???

      J Offline
      J Offline
      JasmineSethi
      wrote on 28 Jan 2019, 15:28 last edited by
      #2
      This post is deleted!
      1 Reply Last reply
      0
      • M Offline
        M Offline
        Moisi
        wrote on 1 Feb 2019, 14:28 last edited by
        #3

        Anybody ?

        1 Reply Last reply
        0

        3/3

        1 Feb 2019, 14:28

        • Login

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