ScrollView no scroll
-
wrote on 5 Oct 2020, 17:36 last edited by
Take the following code:
import QtQuick 2.15 import QtQuick.Controls 2.15 ScrollView { width: 200 height: 200 Rectangle{ width: 1000 height: 1000 color: "red" } }
I would have expected that since Rectangle is bigger than the View that I can scroll horizontally and vertically on default but it does not seem to happen.
Can you tell me why?
-
Take the following code:
import QtQuick 2.15 import QtQuick.Controls 2.15 ScrollView { width: 200 height: 200 Rectangle{ width: 1000 height: 1000 color: "red" } }
I would have expected that since Rectangle is bigger than the View that I can scroll horizontally and vertically on default but it does not seem to happen.
Can you tell me why?
wrote on 5 Oct 2020, 21:45 last edited by Bob64 10 May 2020, 21:47@sandro4912 According to the documentation I think you either need explicitly to set
contentHeight
andcontentWidth
in yourScrollView
to theRectangle
'sheight
andwidth
, or you need to set theimplicitHeight
andimplicitWidth
of theRectangle
to itsheight
andwidth
:contentHeight: real
This property holds the height of the scrollable content.
If only a single item is used within a ScrollView, the content size is automatically calculated based on the implicit size of its contained item.
-
wrote on 5 Oct 2020, 22:02 last edited by
Also, you probably want to set
clip: true
in yourScrollView
. -
wrote on 6 Oct 2020, 16:32 last edited by sandro4912 10 Jun 2020, 16:49
I modified it like this:
import QtQuick 2.15 import QtQuick.Controls 2.15 ScrollView { width: 200 height: 200 clip: true contentHeight: children.height contentWidth: children.width Rectangle{ width: 1000 height: 1000 implicitHeight: height implicitWidth: width color: "red" } }
Now it works.
Last Question. If I run this on a mobile device the view becomes flipable automatically?
-
I modified it like this:
import QtQuick 2.15 import QtQuick.Controls 2.15 ScrollView { width: 200 height: 200 clip: true contentHeight: children.height contentWidth: children.width Rectangle{ width: 1000 height: 1000 implicitHeight: height implicitWidth: width color: "red" } }
Now it works.
Last Question. If I run this on a mobile device the view becomes flipable automatically?
wrote on 8 Oct 2020, 08:29 last edited by Bob64 10 Aug 2020, 08:29@sandro4912 sorry, I can't answer your last question as I do not do mobile development. If you meant flickable then I believe so but I am not sure.
-
wrote on 8 Oct 2020, 13:42 last edited by
Yes correct I mean flickable.
1/6