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 5 - qmlRegisterType gives "module is not installed".
Forum Updated to NodeBB v4.3 + New Features

Qt 5 - qmlRegisterType gives "module is not installed".

Scheduled Pinned Locked Moved QML and Qt Quick
6 Posts 4 Posters 6.7k 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.
  • S Offline
    S Offline
    szulak
    wrote on last edited by
    #1

    Hello,
    I am having a small problem with registering custom type in QML. I believe, I've missed something, anyway, I am having such error:
    @
    qrc:/img/gameContent01.qml:2:1: module "myproject.ui" is not installed
    @

    GameWidget.h
    @
    #ifndef GAMEWIDGET_H
    #define GAMEWIDGET_H

    #include <QObject>
    #include <QString>
    #include <QImage>

    class GameWidget : public QObject
    {
    Q_OBJECT
    Q_PROPERTY(QString title READ getTitle WRITE setTitle NOTIFY titleChanged)

    public:
    explicit GameWidget(QObject *parent = 0) : QObject(parent) { };
    ~GameWidget();

    QString getTitle() const;
    void setTitle(const QString& title);

    signals:
    void titleChanged();

    private:
    QString m_title;
    };
    #endif
    @

    mainwindow.cpp
    @
    MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
    {
    ui->setupUi(this);

    qmlRegisterType<GameWidget>("myproject.ui", 1, 0, "GameWidget");

    ///
    }
    @

    #uml file
    @
    import QtQuick 1.1
    import myproject.ui 1.0
    @

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      Perhaps you are performing the registration too late? Try at least moving it before setupUi() is called.

      (Z(:^

      1 Reply Last reply
      1
      • S Offline
        S Offline
        szulak
        wrote on last edited by
        #3

        [quote author="sierdzio" date="1390303909"]Perhaps you are performing the registration too late? Try at least moving it before setupUi() is called.[/quote]

        I've tried it, and it didn't change anything. I've also tried to add this line in main.cpp, before creating MainWindow object - it also didn't work.

        1 Reply Last reply
        0
        • Q Offline
          Q Offline
          Qnoobish
          wrote on last edited by
          #4

          Facing the same error here, registration is made before loading any QML and I still get the error of the module not being installed when I try to run the QML file.

          My code looks like this:
          @
          int GuiThread::svc(void)
          {
          int argc;
          char *argv[1];
          GuiApplication app;

          qmlRegisterType<ItemsFilter>("backEndComponents", 1,0, "ItemsFilter");
          QQuickView *poView = new QQuickView;

          poView->setSource(QUrl::fromLocalFile&#40;"pkg/visufrwk/pkg/plugins/adapt/dummy.qml"&#41;);
          
          QMainWindow *poMainWindow = new QMainWindow();
          QWidget *poWidget = new QWidget(poMainWindow);
          poWidget = QWidget::createWindowContainer(poView);
          poMainWindow->setCentralWidget(poWidget);
          
          poMainWindow->show();
          
          return app.vRun();
          

          }

          @

          Did anyone find a solution?

          In short, software is eating the world.

          1 Reply Last reply
          0
          • A Offline
            A Offline
            Adversus
            wrote on last edited by
            #5

            Had the same problem when starting a new project. For me the problem was with mixing QDeclarativeComponent with QtQuick 2.3. Replacing QDeclarativeComponent by QQuickItem did the trick.

            Note: make sure that any includes
            @#include <QDeclarativeComponent>@

            in your code are replaced by
            @#include <QQuickItem>@

            Especially in main.cpp. Including both of these gives compile errors on qmlRegisterType as long as QDeclarativeComponent is included so these two headers should not be mixed. Hope this helps anywone with this problem.

            1 Reply Last reply
            0
            • A Offline
              A Offline
              Adversus
              wrote on last edited by
              #6

              Had the same problem when starting a new project. For me the problem was with mixing QDeclarativeComponent with QtQuick 2.3. Replacing QDeclarativeComponent by QQuickItem did the trick.

              Note: make sure that any includes
              @#include <QDeclarativeComponent>@

              in your code are replaced by
              @#include <QQuickItem>@

              Especially in main.cpp. Including both of these gives compile errors on qmlRegisterType as long as QDeclarativeComponent is included so these two headers should not be mixed. Hope this helps anywone with this problem.

              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