Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. [Closed("Solved")]QQuickView Object Property
Forum Updated to NodeBB v4.3 + New Features

[Closed("Solved")]QQuickView Object Property

Scheduled Pinned Locked Moved QML and Qt Quick
1 Posts 1 Posters 773 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • O Offline
    O Offline
    onek24
    wrote on last edited by
    #1

    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..

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved