Problems with Open-Source Downloads read https://www.qt.io/blog/problem-with-open-source-downloads and https://forum.qt.io/post/638946

Qml cannot install my private module while building



  • Hello everyone im stuck with this, i believe there is no syntax error and i will just simply paste my code here to explain;

    execom.h
    @#ifndef EXECOM
    #define EXECOM
    #include <QObject>

    class Execom : public QObject
    {
    Q_OBJECT

    public:
    Execom(QObject *parent = 0);
    signals:

    public slots:
    void runcom(const char *cmd);
    };
    #endif // EXECOM
    @

    execom.cpp
    @
    #include <execom.h>
    #include <stdlib.h>
    #include <unistd.h>

    Execom::Execom(QObject *parent):
    QObject(parent)
    {}

    void Execom::runcom(const char *cmd){

     system&#40;cmd&#41;;
    

    }
    @

    main.cpp
    @
    #include <QApplication>
    #include <QQmlApplicationEngine>

    #include "execom.h"
    #include <QtQml>

    int main(int argc, char *argv[])
    {
    QApplication app(argc, argv);

    QQmlApplicationEngine engine;
    engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
    
    
    qmlRegisterType<Execom>("Komut",1,0,"Execom");
    
    
    
    return app.exec&#40;&#41;;
    

    }
    @

    main.qml
    @
    import QtQuick 2.4
    import QtQuick.Controls 1.3
    import QtQuick.Window 2.2
    import QtQuick.Dialogs 1.2
    import Komut 1.0 // according to error this modul is not installed

    ApplicationWindow {

    ...

    Execom
    {
    id:kod

    }
    MainForm {
        anchors.fill: parent
        button1.onClicked: fileDialog.open(&#41;
        
        button2.onClicked: {
    
    
            command+="tiff2pdf -o /home/stajer/Masaüstü/output.pdf "+texturl
            console.log(""+command)
    
            kod.runcom(command)
            messageDialog.show(qsTr("Button 2 pressed"))
        }
    
    }
    

    FileDialog {

    ...

    @

    the pro file
    @
    TEMPLATE = app

    QT += qml quick widgets

    SOURCES += main.cpp
    execom.cpp

    RESOURCES += qml.qrc

    Additional import path used to resolve QML modules in Qt Creator's code model

    QML_IMPORT_PATH =

    Default rules for deployment.

    include(deployment.pri)

    HEADERS +=
    execom.h
    @

    and the error is this :

    QQmlApplicationEngine failed to load component
    qrc:/main.qml:5 module "Komut" is not installed

    I really can use your help.


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    IIRC you should register your types before loading your qml file


Log in to reply