Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. QT C++ module is not installed
Qt 6.11 is out! See what's new in the release blog

QT C++ module is not installed

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
3 Posts 3 Posters 1.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    darekQT290
    wrote on last edited by
    #1

    I am new to QT. I am writing a demo C++ program integrating to QT. It got the module is not installed error all the time, even I tried several tricks from internet post.

    Here is the code:
    --------------- myclass.h
    #ifndef MYCLASS_H
    #define MYCLASS_H

    #include <QObject>
    #include <QString>

    class MyClass : public QObject
    {
    Q_OBJECT
    public:
    explicit MyClass(QObject *parent = 0);
    Q_INVOKABLE QString sayHello() const;
    };

    #endif // MYCLASS_H
    ------------ myclass.cpp
    #include "myclass.h"

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

    QString MyClass::sayHello() const
    {
    return "Hello!";
    }
    ---------------- main.cpp
    #include <QGuiApplication>
    #include <QQmlApplicationEngine>
    #include <QtQml>
    #include <QQmlContext>
    #include <QQmlEngine>

    #include "myclass.h"

    int main(int argc, char *argv[])
    {
    QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
    QGuiApplication app(argc, argv);
    qmlRegisterType<MyClass>("com.mycompany.myapplication", 1, 0, "MyClass");
    QQmlApplicationEngine engine;
    MyClass myClass;
    engine.rootContext()->setContextProperty("myClass", &myClass);
    engine.load(QUrl(QLatin1String("qrc:/main.qml")));
    return app.exec();
    }
    ---------------- main.qml
    import QtQuick 2.7
    import QtQuick.Controls 2.0
    import QtQuick.Layouts 1.0

    import com.mycompany.myapplication 1.0

    ApplicationWindow {
    visible: true
    width: 640
    height: 480
    title: qsTr("Hello World")

    Text {
        anchors.centerIn: parent
        text: myClass.sayHello()
    }
    

    }
    ------------------ myclass.pro
    QT += quick
    CONFIG += c++11

    DEFINES += QT_DEPRECATED_WARNINGS

    SOURCES +=
    main.cpp
    myclass.cpp

    RESOURCES += qml.qrc

    QML_IMPORT_PATH =

    QML_DESIGNER_IMPORT_PATH =

    qnx: target.path = /tmp/$${TARGET}/bin
    else: unix:!android: target.path = /opt/$${TARGET}/bin
    !isEmpty(target.path): INSTALLS += target

    HEADERS +=
    myclass.h

    I downloaded the latest QT package from the website.
    QT Creator: 4.7.0
    QT 5.11.1 (MSVC 2015, 32 bit)
    Windows 10 PC

    Appreciate for any advice.....

    1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Moderators Qt Champions 2024 Qt Champions 2022 Qt Champions 2017
      wrote on last edited by
      #2

      What is the exact error ? Which module is not installed ? Exact error will help us to see what is the issue.

      I see couple of other issue in your pro file. You should place the back slash at the end of each source file & header file if there are multiple files.

      SOURCES +=
      main.cpp
      myclass.cpp

      Dheerendra
      @Community Service
      Certified Qt Specialist
      https://www.pthinks.com

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi and welcome to devnet,

        This is not the latest version, current is 5.12.
        What exact error are you getting ?
        Did you install Visual Studio 2015 ? If so, did you select the C++ components ?
        On a side note, it's Qt. QT stands for Apple QuickTime which is something else.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved