Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Qml in C++/Qt on Android not visible
Forum Update on Monday, May 27th 2025

Qml in C++/Qt on Android not visible

Scheduled Pinned Locked Moved Mobile and Embedded
4 Posts 4 Posters 1.9k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    Flavia
    wrote on 19 Nov 2014, 13:59 last edited by
    #1

    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 = app

    SOURCES += main.cpp
    mainwindow.cpp

    HEADERS += mainwindow.h

    FORMS += mainwindow.ui

    CONFIG += mobility
    MOBILITY =

    OTHER_FILES +=
    main.qml

    RESOURCES +=
    m.qrc
    @

    [edit: added missing coding tags @ SGaist]

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mcm_qt
      wrote on 21 Nov 2014, 14:55 last edited by
      #2

      Which is the android device? What is the Kernel version?

      You can check Force rendering GPU, option in settings with Android.

      1 Reply Last reply
      0
      • G Offline
        G Offline
        Gianluca
        wrote on 21 Nov 2014, 21:40 last edited by
        #3

        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"));
        @

        1 Reply Last reply
        0
        • M Offline
          M Offline
          metaDom
          wrote on 26 Nov 2014, 14:00 last edited by
          #4

          check this bug:

          https://bugreports.qt-project.org/browse/QTBUG-41467

          1 Reply Last reply
          0

          1/4

          19 Nov 2014, 13:59

          • Login

          • Login or register to search.
          1 out of 4
          • First post
            1/4
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved