I have a QQuickWidget. I'd like to make it autosizable according to its QML content and to provide both horizontal and vertical scrollbars in case when its content cannot fit the window.
I put the QQuickWidget inside a QScrollArea and added layout to the QScrollArea to make the QQuickWidget to fill it. In the parent window constructor I added a line:
scroll_area->setWidget(quick_widget);
However no scroll bars are available, independently on QML content size. How should QQuickWidget and QScrollArea be configured to work as I need?
UPDATE1: Well, I'm trying to make that via QDesigner. Actual UI XML is:
<widget class="QScrollArea" name="scroll_area">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QQuickWidget" name="quick_widget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>502</width>
<height>269</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="resizeMode">
<enum>QQuickWidget::SizeViewToRootObject</enum>
</property>
<property name="source">
<url>
<string>…</string>
</url>
</property>
</widget>
</widget>
And while debugging I can see that QScrollArea.widget() has been already set to quick_widget (without force call scroll_area.setWidget()), but still there are no scrollbars available, even when the quick_widget content cannot fit its size.
UPDATE2: Well there's possibly a problem that items are added dynamically. And perhaps the root object height and width should be modified manually (or they shouldn't?) For example:
if ( object.x + object.width > root.width )
root.width = object.x + object.width;
if ( object.y + object.height > root.height )
root.height = object.y + object.height;