Как я могу правильно включить файл <qtquick>? - PullRequest
0 голосов
/ 24 марта 2020

Я новичок в qml и пытаюсь протестировать простое приложение hello world с использованием файла qml в qt 5.9. Я уже добавил qt+= quick в свой файл .pro, но каждый раз, когда я пытаюсь включить <qtquick> или <qquickview> это происходит:

warning : the code model could not parse an included file which might lead to incorrect code compilation and highlighting for example.

float.h:19:15: error: 'float.h' file not found
main.cpp:1:1: note: in file included from C:\Users\masso\Documents\untitled1\main.cpp:1:
main.cpp:7:10: note: in file included from C:\Users\masso\Documents\untitled1\main.cpp:7:
QQuickView:1:10: note: in file included from C:\Qt\5.9.9\mingw53_32\include\QtQuick\QQuickView:1:
qquickview.h:43:10: note: in file included from C:\Qt\5.9.9\mingw53_32\include\QtQuick\qquickview.h:43:
qquickwindow.h:44:10: note: in file included from C:\Qt\5.9.9\mingw53_32\include\QtQuick\qquickwindow.h:44:
qsgrendererinterface.h:43:10: note: in file included from C:\Qt\5.9.9\mingw53_32\include\QtQuick\qsgrendererinterface.h:43:
qsgnode.h:46:10: note: in file included from C:\Qt\5.9.9\mingw53_32\include\QtQuick\qsgnode.h:46:
float.h:45:17: note: in file included from C:\Qt\Tools\QtCreator\bin\clang\lib\clang\8.0.1\include\float.h:45:

, поэтому я пытаюсь создать привет мир, поэтому я включаю <qtquick> создать экземпляр qquickview, связанный с источником URL-адреса, и выполнить его

#include <QGuiApplication>
#include <QQuickView>

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

    QQuickView view;
    view.setSource(QUrl("qrc:/main.qml"));
    view.show();

    return app.exec();
}

мой .pro файл

QT += quick

CONFIG += c++11

# The following define makes your compiler emit warnings if you use
# any Qt feature that has been marked deprecated (the exact warnings
# depend on your compiler). Refer to the documentation for the
# deprecated API to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS

# You can also make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0

SOURCES += \
        main.cpp

RESOURCES += qml.qrc

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

# Additional import path used to resolve QML modules just for Qt Quick Designer
QML_DESIGNER_IMPORT_PATH =

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

...