QQuickWidget size
-
I don't understand how to handle sizes of a
QQuickWidget
. For example I place it in aQTabWidget
:QQuickWidget _formOverview; _formOverview.setSource(QUrl("qrc:/qml/main.qml")); _formOverview.setResizeMode(QQuickWidget::SizeRootObjectToView); _formOverview.setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); ui->tabView->addTab(&_formOverview, tr("Overview"));
main.qml file:
import QtQuick 2.11 Rectangle { anchors.fill: parent visible: true color: "blue" }
but the size of the rectangle is 0,0.
How to fill the whole area? -
try it without the anchors.fill: parent
Usually, for me at least, the root item of a QQuickWidgets qml file does not have a size specified and matched the parent QQuickWidget automatically.
If I remember correctly, that QQuickView doesn't do that and you would have to specify a size for the root element.
-
@J.Hilk said in QQuickWidget size:
try it without the anchors.fill: parent
Usually, for me at least, the root item of a QQuickWidgets qml file does not have a size specified and matched the parent QQuickWidget automatically.
If I remember correctly, that QQuickView doesn't do that and you would have to specify a size for the root element.
You're right. It works!
I didn't find this information in the documentation, and it's not so intuitive!