Skip to content
  • 0 Votes
    1 Posts
    187 Views
    No one has replied
  • 0 Votes
    3 Posts
    348 Views
    J

    Hey @ndias,
    I am trying to attach to a QQuickWindow.
    After some more try & error I finally managed to get it working by using createWithInitialProperties like so:

    initialProperties = {"parent": window.contentItem()} object = component.createWithInitialProperties(initialProperties, engine.rootContext())
  • 0 Votes
    5 Posts
    612 Views
    haikuH

    I've just tested out the QQuickWidget class and it's working as I hoped. I can give each QQuickWidget it's own separate QMLEngine instance and the qml items inside each widget are not able to reach out into Qt widget land.

    There are still a few issues I'm looking into though regarding displaying one QQuickWidget over another. I've worked out how to make the top widget transparent but I'm still looking into event handling and how to stop the top QQuickWidget from eating events that should really be processed by the bottom QQuickWidget. I'm sure it's possible though.

    It's a shame that this isn't possible from QML itself. It'd be lovely to have a option you just pass to a Loader to say to sandbox the loaded item or something along those lines but this will work for now.

  • 0 Votes
    1 Posts
    278 Views
    No one has replied
  • 0 Votes
    5 Posts
    981 Views
    T

    @ambershark @mranger90
    I saw your code, There is a major difference between the way you are running the application and I am running the application.
    If I run the application as a qml application, the application runs well. No problem at all.

    However, I am trying to run it the way a scripting language should work or what I expect it to work.
    I am running the main.qml without including in the Resources. I want to be able to do that at run time. Including it in Resources defeats the purpose.

    Secondly, I am running the qml through the mainform.cpp at runtime. So Ideally i want to select the qml file to run and then run it.
    Which works as far as running the qml is concerned. However, when it comes to interaction of the testing.cpp and the qml, that does not work.

    I have attached the zip of the complete project in qtcreator FYI.

    [0_1536639580948_scripttest1.zip](Uploading 100%)

  • 0 Votes
    4 Posts
    5k Views
    KillerSmathK

    @devDawg

    In memory, resources are represented by a tree of resource objects. The tree is automatically built at startup and used by QFile for resolving paths to resources. You can use a QDir initialized with ":/" to navigate through the resource tree from the root.

    So, you could use:

    QQmlComponent comp(&engine,QUrl("qrc:/Display0.qml")); QFile file(":/Display0.qml"); // acessing by resource tree

    NOTE: QStringLiteral is a optimization case, you can use QStringLiteral to avoid the implicit conversion between char* to QString and then copy the data.

    References:
    Qt Resource Documentation - Using resource in the application
    QStringLiteral Explanation

  • 0 Votes
    8 Posts
    4k Views
    M

    @romsharkov
    Hi there,

    Do I understand correctly that you have managed to run a QQmlProcess in a separate process?

    I am asking it because I have came across pretty much the same problem:
    https://github.com/sailfish-sdk/sdk-harbour-rpmvalidator/pull/79#issuecomment-307348648

    If you could tell me some words of you implementation details that would be awesome!
    Thanks in advance!

  • 0 Votes
    2 Posts
    904 Views
    romsharkovR

    I got it to work with the following line:

    obj->setProperty("parent", QVariant::fromValue<QObject*>(viewport));

    now everything's fine, anyway.. am I doing everything correctly here?

    It's strange that it's not documented

  • 0 Votes
    11 Posts
    9k Views
    p3c0P

    @nwoki Didn't anticipate that :D
    Congratulations and Happy Coding :)

  • 0 Votes
    2 Posts
    3k Views
    p3c0P

    Hi @AmalRaj and Welcome,
    Whenever you create an item using QQmlComponent and create you must set it a visual parent using setParentItem. For that you will need to cast it to QQuickItem otherwise it wont be displayed

    QQmlComponent component(&engine, QUrl(QStringLiteral("qrc:/Game.qml"))); QQuickItem *object = qobject_cast<QQuickItem*>(component.create());

    Then try setting its properties.

    P.S: The forum use markdown syntax. So while posting code surround it with ``` (3 backticks) so that it appears more readable. I have edited it this time.