Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
qtws26_logo

The Qt Event of the Year: Qt World Summit 2026

Save Your Spot >
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QmlJS::ModelManagerInterface - getting semantic info out of QML file
Qt 6.12 LTS is out! See what's new in the release blog

QmlJS::ModelManagerInterface - getting semantic info out of QML file

Scheduled Pinned Locked Moved General and Desktop
1 Posts 0 Posters 1.6k 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.
  • ? This user is from outside of this forum
    ? This user is from outside of this forum
    Guest
    wrote on last edited by
    #1

    Hi,

    Currently I'm developing plugin for Qt Creator which should give me semantic information based on user location in QML file opened in text editor (where cursor is set). For example, if we have the following QML file:
    @
    Rectangle {
    width: 200
    height: 200
    color: "blue"

    Image {
        source: "pics/logo.png"
        anchors.centerIn: parent
    }
    

    }
    @

    and user clicks on color:"blue" plugin should tell that it is inside Rectangle object.
    I tried to use the following code:
    @
    const QmlJS::Snapshot snapshot = modelManager->snapshot();
    const QmlJS::Document::Ptr doc = snapshot.document(fileName);
    QmlJS::AST::Node *node = doc->ast();
    const QmlJS::Interpreter::ObjectValue *scopeObject = doc->bind()->findQmlObject(node);
    qDebug() << "QML class" << scopeObject->className();
    @

    but scopeObject returned is null. ast() and bind() of document are also null, though the document->source shows the correct source file and it is parsed. The question is how to get the scopeObject or are there any other ways to do this. I get modelManager from QMLJS::ModelManagerInterface instance.

    Cheers

    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
    • Unsolved