error: 'qmlRegisterType' was not declared in this scope

Aquarius_Girl picture Aquarius_Girl · Oct 30, 2013 · Viewed 8.9k times · Source

Working with Qt 5 and QtQuick 2.0

.pro

# Add more folders to ship with the application, here
folder_01.source = qml/untitled
folder_01.target = qml
DEPLOYMENTFOLDERS = folder_01

# Additional import path used to resolve QML modules in Creator's code model
QML_IMPORT_PATH =

# If your application uses the Qt Mobility libraries, uncomment the following
# lines and add the respective components to the MOBILITY variable.
# CONFIG += mobility
# MOBILITY +=

#CONFIG += qt plugin
#QT += qml quick

# The .cpp file which was generated for your project. Feel free to hack it.
SOURCES += main.cpp \
    ../DummyClass.cpp \
    ../aa.cpp

# Installation path
# target.path =

# Please do not modify the following two lines. Required for deployment.
include(qtquick2applicationviewer/qtquick2applicationviewer.pri)
qtcAddDeployment()

HEADERS += \
    ../DummyClass.h \
    ../aa.h

main.cpp

#include <QtGui/QGuiApplication>
#include "qtquick2applicationviewer.h"
#include "/home/***/qmllistproperties/DummyClass.h"

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

    const char* ocuui = "OCUUI"; // @uri OCUUI

    qmlRegisterType <DummyClass> (ocuui, 1, 0, "DummyClass");

    QtQuick2ApplicationViewer viewer;
    viewer.setMainQmlFile(QStringLiteral("qml/untitled/main.qml"));
    viewer.showExpanded();

    return app.exec();
}

Answer

thuga picture thuga · Oct 30, 2013

qmlRegisterType is in QtQml. You have to include QtQml:

#include <QtQml>