Work on QString Error for Mobile

I am trying to run a simple button on QML Android with C ++.

Compile and create the program using QString / QQmlEngine . When I try to start it, it displays the following message:

kernel/qcoreapplication.cpp:418 (QCoreApplicationPrivate::QCoreApplicationPrivate(int&, char**, uint)): 
WARNING: QApplication was not created in the main() thread.

Which seems to be normal, as indicated here: QApplication In Non-Main Thread . Then it displays a message:

qrc:///calculator.qml:33 ((null)): 
qrc:///calculator.qml:33:15: Unable to assign [undefined] to QString

I read that this is an unconfirmed error given here: Qt Project - QTMOBILITY-1735 . Similar error-related issues also affect " " There is no stencil buffer support, expect display errors, "as I am developing for the Tablet. If this is a really related error that seems to be there, is there any possible way to fix it “There must be some possible hack to handle this. Essentially, it blocks almost everything in order to escape.”

The code is simple and small, since I use it as a framework that simply launches a button on the target device. Here is a short program that I use to try to get the job to work.

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

, - .

+4
1

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 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 , , , .

, .

+4

All Articles