QML object size within a Qt (C++) gridlayout
-
I have a Qt (C++) gridlayout. One of the objects in this layout is a QQuickWidget and one of the SizePolicies of this QQuickWidget widget is Expanding, so the size of the QQuickWidget can vary. I also construct a ChartView in QML and I display this in the QQuickWidget. I luse C++ to load the ChartView into the QQuickView and to display it. The work of the QML is to construct the ChartView. Diagramatically:
QML ----------> Qt
QChartView -> QQuickViewMy problem is to ensure that the ChartView fills the whole screen area available to the QQuickView. At the moment I need to specify the width and height of the Chartview in pixels and the size of the ChartView is not dynamically scaled to that of the enclosing QQuickView. See attached image.
image url)
The value of parent.width is zero, so that is not useful. If I do not specify height/width of the ChartView, they are assumed to be zero so nothing is displayed.
Is there a way to scale the ChartView to fill the whole of the available screen space?
-
@willemf Hi,
Did you set the resizeMode of your QQuickWidget to QQuickView::SizeRootObjectToView. According to the doc it should resize your root QML element according to QQuickWidget size.