I am trying to run a simple button on QML Android with C++.
The program compile and build using QString/QQmlEngine. When I try to run it, it gives this message:
kernel/qcoreapplication.cpp:418 (QCoreApplicationPrivate::QCoreApplicationPrivate(int&, char**, uint)):
WARNING: QApplication was not created in the main() thread.
Which apparently is normal as quoted here: QApplication In Non-Main Thread . Then it gives the message:
qrc:///calculator.qml:33 ((null)):
qrc:///calculator.qml:33:15: Unable to assign [undefined] to QString
I read that it is an unconfirmed bug, as quoted here: Qt Project - QTMOBILITY-1735. Such kind of bug related problems also affects the "Stencil buffer support missing, expect rendering errors", as I am developing for Tablet. If this is really a related bug, which seems to be case, there is any possible way around it? There should be some kind of possible hack to work this out. Basically, this is blocking almost everything to run.
The code is simple and small, as I am using it as framework, which simply makes a button run on the target device. Here is the short program, that I am using to try to get things to start working.
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();
}
calculator.qml
import QtQuick 2.0
import QtSensors 5.0
import QtQuick.Controls 1.0
Rectangle {
id: button
property bool checked: false
property alias text : buttonText.text
Accessible.name: text
Accessible.description: "This button does " + text
Accessible.role: Accessible.Button
function accessiblePressAction() {
button.clicked()
}
signal clicked
width: buttonText.width + 20
height: 30
gradient: Gradient {
GradientStop {
position: 0.00;
color: "#b0c4de";
}
}
radius: 5
antialiasing: true
Text {
id: buttonText
text: parent.description
anchors.centerIn: parent
font.pixelSize: parent.height * .5
style: Text.Sunken
color: "white"
styleColor: "black"
}
MouseArea {
id: mouseArea
anchors.fill: parent
onClicked: parent.clicked()
}
Keys.onSpacePressed: clicked()
}
calculator.pro
QT += qml quick sensors svg xml
OTHER_FILES += \
calculator.qml
RESOURCES += \
calculator.qrc
SOURCES += \
calculator.cpp
I hope someone could come along with some suggestion.