papyros / qml-material

:book: Material Design implemented in QtQuick
GNU Lesser General Public License v2.1
2.56k stars 476 forks source link

import Material 0.3 does nothing #468

Open afendin opened 8 years ago

afendin commented 8 years ago

Qt 5.7 Windows 10 What i have done step by step: 1.Created QtQuick Application(with git init) 2.git submodule add git@github.com:papyros/qml-material.git material 3.My pro file `TEMPLATE = app

QT += qml quick CONFIG += c++11

SOURCES += main.cpp

RESOURCES += qml.qrc

DEFINES += QPM_INIT(E)=\"E.addImportPath(QStringLiteral(\"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) include(material/material.pri) `

4. My main.cpp file

`#include QGuiApplication

include QQmlApplicationEngine

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

QQmlApplicationEngine engine;
QPM_INIT(engine)
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));

return app.exec();

} `

5. import Material 0.3 does not work

what's wrong?

alexhochreiter commented 8 years ago

Because of #442 you should replace QPM_INIT(engine) with engine.addImportPath("qrc:/Material"); But let me guess, it still won't work? Can you please edit your main.cpp file to check if the qmldir of Material is beeing at the right place at all?

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

    QFile f(":/Material/qmldir");
    f.open(QIODevice::ReadOnly);
    qDebug() << f.readAll();

    QQmlApplicationEngine engine;
    engine.addImportPath("qrc:/Material");
    engine.load(QUrl(QStringLiteral("qrc:/main.qml")));

    return app.exec();
}

Then it should also be enough to just define QPM_INITin your .pro file DEFINES += QPM_INIT

afendin commented 8 years ago

thanks sir, i'm currently using QtQuick.Controls.Material 2.0 and everything ok