Qml in C++/Qt on Android not visible
-
wrote on 19 Nov 2014, 13:59 last edited by
Hello,
I have the problem that the QML part of my file is not shown on Android device. It works fine on Windows 8.1 Desktop (Qt 5.3). But on Android it only flashes the QML part for a moment and than the box disappears. What did I wrong?
- My QML file is a simple one and it is stored on the Resouce file:
@
import QtQuick 2.0
Rectangle {
id: rectangle
color: "red"
width: 200
height: 100
}
@AND the resource file called "m.qrc":
@
<RCC>
<qresource prefix="/">
<file>main.qml</file>
</qresource>
</RCC>
@- In mainwindow.cpp I have the code:
@
#include<QtQuick/QQuickView>
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);QQuickView *view = new QQuickView(); QWidget *container = QWidget::createWindowContainer(view, this); container->setGeometry(5,25,300,130); view->setSource(QUrl("qrc:/main.qml"));
}
MainWindow::~MainWindow()
{
delete ui;
}
@- In the .pro file I have the code
@
QT += core gui
TEMPLATE += app
QT += quick
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = ContC2
TEMPLATE = appSOURCES += main.cpp
mainwindow.cppHEADERS += mainwindow.h
FORMS += mainwindow.ui
CONFIG += mobility
MOBILITY =OTHER_FILES +=
main.qmlRESOURCES +=
m.qrc
@[edit: added missing coding tags @ SGaist]
- My QML file is a simple one and it is stored on the Resouce file:
-
wrote on 21 Nov 2014, 14:55 last edited by
Which is the android device? What is the Kernel version?
You can check Force rendering GPU, option in settings with Android.
-
wrote on 21 Nov 2014, 21:40 last edited by
Did you need the QWidgets ??
Because, if you don't need them, it's better to use a QQuickView directly into main.cpp:
@
QQuickView viewer;
viewer.setResizeMode( QQuickView::SizeRootObjectToView );
viewer.setSource( QUrl("qrc:/main.qml") );
viewer.show();return app.exec();
@If you need QWidget, then do not use the createWindowContainer that it has been replaced by QQuickWidget:
@
QQuickWidget *view = new QQuickWidget;
view->setGeometry(5,25,300,130);
view->setSource(QUrl("qrc:/main.qml"));
@ -
wrote on 26 Nov 2014, 14:00 last edited by
check this bug:
1/4