How to integrate C++ and QML

preview_player
Показать описание
In this video we explore the basics of integrating QML and C++. We start with a pre-written QML application and will focus on how to write a C++ class which can be exposed to QML.

This example was written using the following...
Qt 6.5.2 MinGw 64 Bit
Qt Creator 11.0.1 (Enterprise)
Рекомендации по теме
Комментарии
Автор

Show! Este vídeo está me ajundo muito! Continue postando mais vídeos incríveis assim... Thank you!

Roberto-kdjg
Автор

Maybe raise a support ticket or post on the forum with a cut down example.

MikeTrahearn
Автор

What if my "C++ Backend" is a C++20 Module, created as an Extension Plugin?

I couldn't just add my *.cppm* files as the values for SOURCE and that's it, right?!, since the C++ Module/Plugin itself has its own "qt_add_module..." characteristics (you can see how it is defined by following the Qt Creator Wizard for a Qt Quick 2 Extension Plugin).

I mean, my Module doesn't know of a Main.qml file "yet", as in your case, where you directly pass the QML File to the QML FILES Variable.
It's when I create the QML Quick App that I'll want to import my Library of Modules, so I can use them inside the QML Files. They're all inside a folder called import. I need to make sure they're are visible to the Project and that I can statically link them.

So, yeah, I'm sort of lost bringing in my C++ Modules (Data Models/Sources, Controllers) to use with a QML View 😅

This is the only problem we're having - we would like to use QML for our GUIs/Views, but have everything as C++20 Modules (we ain't going back to raw headers, #includes, etc. 😂)

Thanks in advance.

theintjengineer
Автор

the C++ class used in this demo is named "Backend". I got lost in 6:53 when the Button.onclicked() uses an unknown class named "myBackend"...???

paradox_
Автор

QtQml is not always the best include for your type registration macros - depends on whether you want to link to QtQml or not. If you've not had that argument with your boss yet - you will do, so be prepared 😔

MikeTrahearn
Автор

I have followed you steps, but when i added "import <myURIName>" it seems that qml file dont see Backend at all, i have red underline and yellow message saying "QML module contains C++ plugins, currently reading type information...".

Anybody have idea what does it mean?

marektengler
Автор

bruh, import CppIntegration QML module not found, what's wrong?

shuxiang
Автор

Lewis Karen Thompson Paul Johnson Richard

DanetteKshlerin
Автор

Hernandez Jessica Garcia Carol Lee Jessica

JackMaxwell-yt
Автор

WE KNOW HOW TO CREATE A CLASS. SHOW US THE DAMN WAY TO CREATE THE PLUGIN, I'M TIRED OF THE DOCS.

and_then_I_whispered