[Development] Using qml.exe with a custom QML_ELEMENT plugin

Elias Steurer kelteseth at googlemail.com
Wed Oct 25 12:34:18 CEST 2023


According to dependency scanner it depends on Qt6Qml.dll, Qt6Core.dll 
and World.dll. All of these should be either be available from Qt or 
from the additional import path I provided. Even when copying the dlls 
into the directory, I get the same error.

PS C:\Qt\6.7.0\msvc2019_64\bin> .\qml.exe -I 
"C:\Code\Cpp\build-qml-plugin-minimal-Desktop_Qt_6_7_0_MSVC2019_64bit-Release" 
-f "C:\Code\Cpp\qml-plugin-minimal\Main.qml"
QQmlApplicationEngine failed to load component
file:///C:/Code/Cpp/qml-plugin-minimal/Main.qml:5:1: Die Bibliothek 
C:\Code\Cpp\build-qml-plugin-minimal-Desktop_Qt_6_7_0_MSVC2019_64bit-Release\Hello\World\Worldplugin.dll 
kann nicht geladen werden: Das angegebene Modul wurde nicht gefunden.
qml: Did not load any objects, exiting.


The Hello class contains just a single function:

#pragma once
#include <QObject>
#include <QQmlEngine>
#include <QDebug>

class Hello : public QObject {
     Q_OBJECT
     QML_ELEMENT

public slots:
     void speak();
};

*and my test qml:*

import QtQuick
import QtQuick.Layouts
import QtQuick.Controls
import QtQuick.Controls.Material
import Hello.World 1.0

Window {
     width: 640
     height: 200
     visible: true
     title: qsTr("Test Project")
     Hello {

     }

}

*Main CMakeListst.txt*

cmake_minimum_required(VERSION 3.16)

project(qmlmodule VERSION 1.0.0 LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

find_package(Qt6 REQUIRED COMPONENTS Qml)
qt_standard_project_setup(REQUIRES 6.5)

add_subdirectory(Hello/World)

*plugin CMakeListst.txt:*

qt_add_qml_module(World
   URI
   Hello.World
   VERSION
   1.0
   SOURCES
   Hello.cpp
   Hello.h)

Am 25.10.2023 um 10:45 schrieb Ulf Hermann via Development:
>> PS C:\Qt\6.7.0\msvc2019_64\bin> /.\qml.exe -I 
>> "C:\Code\Cpp\build-qml-plugin-minimal-Desktop_Qt_6_7_0_MSVC2019_64bit-Release" 
>> -f "C:\Code\Cpp\qml-plugin-minimal\Main.qml"
>> QQmlApplicationEngine failed to load component
>> file:///C:/Code/Cpp/qml-plugin-minimal/Main.qml:5:1: Die Bibliothek 
>> C:\Code\Cpp\build-qml-plugin-minimal-Desktop_Qt_6_7_0_MSVC2019_64bit-Release\Hello\World\Worldplugin.dll 
>> kann nicht geladen werden: Das angegebene Modul wurde nicht gefunden.
>> qml: Did not load any objects, exiting./
>
> On windows, you have to jump through some hoops to make it find the 
> backing library. There is PATH. You can install the backing library in 
> some place that's already on your PATH or you can adapt PATH. If you 
> have a custom executable you can also install the backing library next 
> to it.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20231025/d386c380/attachment.htm>


More information about the Development mailing list