qmlnet/samples/hosting
2018-12-25 22:09:07 -05:00
..
native Documenting the self-hosting stuff. [skip ci] 2018-09-12 17:43:35 -04:00
net Updating to netcoreapp2.2. 2018-12-25 22:09:07 -05:00
.gitignore Added support for c++ to main entry point. 2018-09-11 20:21:00 -04:00
README.md typos [skip ci] 2018-09-12 17:45:17 -04:00

Hosting

Purpose

Most of the time, it is easier to have .NET serve the entry point of your application (Program.cs). This approach works consistently across platforms and IDEs.

However, sometimes you need greater control over how Qt is initialized on start. Or, you have some C/C++ code that needs to be run before the applications stars. Or, you need to register custom QObject classes with QML. You get the idea.

Regardless, the following approach allows you to create a Qt project in tradtional way (with .qrc files, linked libs, etc) while still using Qml.Net.

Benefits

  • Traditional Qt/QML application with complete control over the generated main executable.
  • No need for the Qml.Net.*Binaries packages since the native components needed for Qml.Net are linked in the main executable and passed to .NET via magic.

Running the sample

Running the sample is straight forward. It is the best way to get the gist of how things are working (it's simple, IMO).

  • Step 1: Build the .NET entrypoint application.
cd net
dotnet build
  • Step 2: Open native/NativeHost.pro in Qt Creator and run it.

That's it.

The interesting parts

Follow phases 1-9 across the following files: