Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QmlJS::ModelManagerInterface - getting semantic info out of QML file
Forum Update on Monday, May 27th 2025

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

Scheduled Pinned Locked Moved General and Desktop
1 Posts 0 Posters 1.4k Views
  • 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 23 Nov 2011, 12:45 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

    1/1

    23 Nov 2011, 12:45

    • Login

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