Quantcast
Channel: Qt DevNet forums: Qt Quick 1283365070**
Viewing all articles
Browse latest Browse all 4972

[Closed("Solved")]QQuickView Object Property

$
0
0
When i am creating a QObject pointer which points at the rootObject of a QDeclarativeView and i try to get a property value from QML with the function property(), it works, but when i am using a QQuickView instead of a QDeclarativeView, then i get a read access violation. QDeclarativeView: QObject *object = (QObject*)ui->declarativeView->rootObject(); ui->declarativeView->setSource(QUrl("qrc:/qml/main.qml")); qDebug(object->property("imageBorderColor")); Output: _QVariant(QColor, QColor(ARGB 1, 0, 0, 0) ) _ QQuickView: QQuickView *view = new QQuickView(); view->setSource(QUrl("qrc:/qml/main.qml")); object = (QObject*)view->rootObject(); context = view->rootContext(); container = QWidget::createWindowContainer(view, this); container->setGeometry(0, 0, 1440, 810); container->show(); qDebug(object->property("imageBorderColor")); main.qml in QDeclarativeView project import QtQuick 1.1   Rectangle {     id: mainFrame     property color imageBorderColor: "black"     ... } main.qml in QQuickView project: import QtQuick 2.0 import QtQuick.Controls 1.0 import QtQuick.Window 2.0   Rectangle {     id: mainFrame     property color imageBorderColor: "black"     ... } Is there a way to solve this or any other way to access QML properties from Cpp using a QQuickView? Oh and i also tried: QDeclarativeProperty::write(object, "imageBorderColor", "red"); — Update — It looks like QQuickView did not provide a rootObject. How is that possible? — Update — Very strange, i was searching for a solution and i couldn’t find one, but it worked fine after restarting Qt..

Viewing all articles
Browse latest Browse all 4972

Trending Articles