Build QML into an EXE



  • I want to make a skinned Windows desktop application, and want to seperate the GUI with the logic, so that later the application can change the skin

    dymatically, like WinAMP.

    After contacting support of Qt, they recommend me to use QML technology.

    I understand the way to load QML file dymatically when the application is running, as below:

    @
    int main(int argc, char **argv)
    {
    QApplication app(argc, argv);
    QDeclarativeView view;
    view.setSource(QUrl::fromLocalFile("myqmlfile.qml"));
    view.show();
    return app.exec();
    }
    @

    However, in such a case, I cannot find a way to bind the events(such as button click event) with the event handler(logic) written in C++(except to use a

    PlugIn, which is undesirable). Can anyone helps?

    Thanks

    Alan

    Edit: added the code tags, gerolf



  • If you want your application to be based on QML, you probably won't have to interact with something like a button click event. After all, what you load in the viewer is your User Interface. But, for interacting with other C++/Qt functionality, you better read here:

    "http://doc.qt.digia.com/4.7-snapshot/qtbinding.html":http://doc.qt.digia.com/4.7-snapshot/qtbinding.html

    "http://doc.qt.digia.com/4.7-snapshot/qml-extending.html":http://doc.qt.digia.com/4.7-snapshot/qml-extending.html



  • Hi,

    I check your two links.

    It seems QML is mainly used as a fast prototype in software engineering, that is, quickly building a software GUI so that the customer and know what is the look & feel of their application. However, the final delivered application may be better to use the pure Qt technology.

    Am I correct?

    Thanks



  • No. QML is perfectly suitable for the end product.
    It is true that QML allows for rapid prototyping for GUIs, but that does not mean that the system isn't suitable for the end product as well. It is true that you'd mostly keep only the GUI in QML, and write the application logic in C++. However, doing it all in QML + Javascript is possible as well.

    Edit:
    Anyway, to put the QML into your .exe, load the QML from a Qt resource instead of from a file on disk.



  • OK. I see. Thank you so much. It seems:

    1. If I using C++, then all the programming logic must be put outside.

    2. If put QML as a Qt resource, then it is possible for others to take the QML outside the program and decode the programming logic, which is undesirable for most of the cases.

    Thanks


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.