Qt: Difference between revisions
imported>Tobias.bora No edit summary |
imported>Tobias.bora No edit summary |
||
Line 163: | Line 163: | ||
* [https://stackoverflow.com/questions/18663331 How to check the selected version of Qt in a .pro file?] | * [https://stackoverflow.com/questions/18663331 How to check the selected version of Qt in a .pro file?] | ||
== Hello world involving QML, Qt5, cmake | == Hello world involving QML, Qt5, nix and cmake, qmake or meson == | ||
You can find [https://gist.github.com/tobiasBora/04d0febda0b3f09707b5e1b7b85390a5 here] a minimal example to use QML, cmake, nix and Qt5, and [https://gist.github.com/tobiasBora/6f114cca1affb5528c872ca01d7e28c1 here] is the same example with qmake instead. There is nothing special to nix there, but note that if you provide the qml file using something like <code>qrc:///main.qml</code>, then you need to write a qrc file that lists all the resources that must be included in the qt resource manager. This file is then used to compile the resources and include them in the binary (you have to compile the binaries, either automatically with cmake or qmake, or manually using rcc). With cmake you compile it using <code>qt5_add_resources(SOURCES qml.qrc)</code> ([https://doc.qt.io/qt-5/qtcore-cmake-qt5-add-resources.html doc]) as illustrated in the above example (make sure to use a variable as the source and to reuse the same variable in <code>add_executable</code>). | You can find [https://gist.github.com/tobiasBora/04d0febda0b3f09707b5e1b7b85390a5 here] a minimal example to use QML, cmake, nix and Qt5, and [https://gist.github.com/tobiasBora/6f114cca1affb5528c872ca01d7e28c1 here] is the same example with qmake instead. There is nothing special to nix there, but note that if you provide the qml file using something like <code>qrc:///main.qml</code>, then you need to write a qrc file that lists all the resources that must be included in the qt resource manager. This file is then used to compile the resources and include them in the binary (you have to compile the binaries, either automatically with cmake or qmake, or manually using rcc). With cmake you compile it using <code>qt5_add_resources(SOURCES qml.qrc)</code> ([https://doc.qt.io/qt-5/qtcore-cmake-qt5-add-resources.html doc]) as illustrated in the above example (make sure to use a variable as the source and to reuse the same variable in <code>add_executable</code>). |