解决QString移动错误 我试图用C++在QML Android上运行一个简单的按钮。p>
程序使用编译和构建。当我尝试运行它时,它会显示以下消息:解决QString移动错误 我试图用C++在QML Android上运行一个简单的按钮。p>,android,c++,qt,mobile,android-ndk,Android,C++,Qt,Mobile,Android Ndk,程序使用编译和构建。当我尝试运行它时,它会显示以下消息: kernel/qcoreapplication.cpp:418 (QCoreApplicationPrivate::QCoreApplicationPrivate(int&, char**, uint)): WARNING: QApplication was not created in the main() thread. 这显然是正常的,这里引用:。然后它给出了一个信息: qrc:///calculator.qml:33
kernel/qcoreapplication.cpp:418 (QCoreApplicationPrivate::QCoreApplicationPrivate(int&, char**, uint)):
WARNING: QApplication was not created in the main() thread.
这显然是正常的,这里引用:。然后它给出了一个信息:
qrc:///calculator.qml:33 ((null)):
qrc:///calculator.qml:33:15: Unable to assign [undefined] to QString
我读到这是一个未经证实的错误,这里引用:。这类与bug相关的问题也会影响到“”,因为我正在为平板电脑开发。如果这真的是一个相关的bug(看起来是这样的),有什么可能的解决方法吗?应该有某种可能的黑客来解决这个问题。基本上,这会阻塞几乎所有要运行的内容
代码很简单,很小,因为我将其用作框架,只需在目标设备上运行一个按钮。这是一个简短的程序,我用它来让事情开始运作
main.cpp
#include <QtGui/QGuiApplication>
#include <QtQml/QQmlApplicationEngine>
#include <QtQml/QQmlEngine>
int main(int argc, char *argv[])
{ QGuiApplication app(argc, argv);
QQmlApplicationEngine engine(QUrl("qrc:///calculator.qml"));
return app.exec();
}
计算器
QT += qml quick sensors svg xml
OTHER_FILES += \
calculator.qml
RESOURCES += \
calculator.qrc
SOURCES += \
calculator.cpp
我希望有人能提出一些建议。当前版本中的文件calculator.pro显然是错误的。它应该看起来更像这样:
# Add more folders to ship with the application, here
folder_01.source = qml/calculator
folder_01.target = qml
DEPLOYMENTFOLDERS = folder_01
QT += qml quick sensors svg xml
# Additional import path used to resolve QML modules in Creator's code model
QML_IMPORT_PATH =
# The .cpp file which was generated for your project. Feel free to hack it.
SOURCES += main.cpp
# Installation path
# target.path =
# Please do not modify the following two lines. Required for deployment.
include(qtquick2applicationviewer/qtquick2applicationviewer.pri)
qtcAddDeployment()
创建新项目时,将自动生成文件qtquick2applicationviewer。因此,您需要将其包括在main.cpp中:
#include "qtquick2applicationviewer.h"
特别是关于消息“无法将QString分配给QQuickItem”,这似乎是qml文件中的某些sintax或参数定义问题,因为您可能需要查看一下
这应该是您的项目出现问题的原因。您使用的是过时的移动设备吗?根据你提到的错误报告,它似乎已被修复。@Laszlo Papp-谢谢你的询问。我正在开发的设备运行在Android 4.3上。我还更新了我的问题中的错误问题,正如您可以检查的那样,我也引用了错误QTBUG-30528。
#include "qtquick2applicationviewer.h"