Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QML > Qt > Android
Forum Updated to NodeBB v4.3 + New Features

QML > Qt > Android

Scheduled Pinned Locked Moved General and Desktop
10 Posts 3 Posters 6.2k Views 1 Watching
  • 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
    fant
    wrote on last edited by
    #1

    Hello,

    I hope, I am right here, I have a little question:

    In Qt Quick 2.0 I create a gui thats uses two states. Then I compile this in Qt 5. There both states unexpectedly are displayed side by side. And if I want to compile this for Android, I just see an empty window.
    Also if I only create a blue rectangle in QML: In Qt all it's ok, but on Android there is only an empty space.
    What can I do?

    Thank you for answers.

    1 Reply Last reply
    0
    • F Offline
      F Offline
      flaviomarcio
      wrote on last edited by
      #2

      I have watched as their problems.
      Want to use QML in android, but I want to use QWidget, and I'm always wrong. But until now pure QML worked well with me since well configured.

      Flavio Portela

      1 Reply Last reply
      0
      • F Offline
        F Offline
        flaviomarcio
        wrote on last edited by
        #3

        Examples of Qt, worked well with me.

        And they worked as follows. The QML and images are within a file.qrc and then run the main.

        I'm waiting out 5.2, but until we live malfunctions.

        Hope this helps.

        Flavio Portela

        1 Reply Last reply
        0
        • F Offline
          F Offline
          fant
          wrote on last edited by
          #4

          At first, thank you for your post. Unfortunately, I don't really understand.. the QML becomes automatically included in qrc-file or have I to do anything for this?
          What I did until now: I create this main.cpp to import there QML. So I can compile it.

          @
          #include <QApplication>
          #include <QtQml/QQmlEngine>
          #include <QtQuick/QQuickView>

          int main(int argc, char *argv[]) {
          QApplication app(argc, argv);
          QQuickView view;
          view.setSource(QUrl::fromLocalFile("QtState.qml")); //QML-file
          view.show();
          return app.exec();
          }
          @

          So the project-file is configured:

          @
          QT += qml quick
          greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

          TARGET = QtAnd
          TEMPLATE += app

          SOURCES += main.cpp
          HEADERS +=

          CONFIG += mobility
          MOBILITY =

          OTHER_FILES += QtState.qml
          @

          Could it be, there is anything wrong?

          1 Reply Last reply
          0
          • raven-worxR Offline
            raven-worxR Offline
            raven-worx
            Moderators
            wrote on last edited by
            #5

            i think you have to add the QtState.qml file to qrc and load it like this:
            @
            view.setSource(QUrl("qrc:///QtState.qml"));
            @
            instead of loading it from the filesystem. Just add it to the OTHER_FILES variable in your PRO file isn't enough.

            --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
            If you have a question please use the forum so others can benefit from the solution in the future

            1 Reply Last reply
            0
            • F Offline
              F Offline
              fant
              wrote on last edited by
              #6

              Unfortunately it didn't help, although I think I am further because of you now. Perhaps in Qt 5.2 it becomes more easier or I find another way.. :(

              1 Reply Last reply
              0
              • raven-worxR Offline
                raven-worxR Offline
                raven-worx
                Moderators
                wrote on last edited by
                #7

                show your code (PRO, qrc, cpp) files again please.

                --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                If you have a question please use the forum so others can benefit from the solution in the future

                1 Reply Last reply
                0
                • F Offline
                  F Offline
                  fant
                  wrote on last edited by
                  #8

                  Yup. There is my PRO-file:

                  @
                  QT += qml quick

                  greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

                  TARGET = QtAnd
                  TEMPLATE += app

                  SOURCES += main.cpp

                  HEADERS +=

                  CONFIG += mobility
                  MOBILITY =

                  OTHER_FILES +=
                  QtState.qml
                  android/AndroidManifest.xml
                  android/res/layout/splash.xml
                  android/res/values/libs.xml
                  android/res/values/strings.xml
                  android/res/values-de/strings.xml
                  android/res/values-el/strings.xml
                  android/res/values-es/strings.xml
                  android/res/values-et/strings.xml
                  android/res/values-fa/strings.xml
                  android/res/values-fr/strings.xml
                  android/res/values-id/strings.xml
                  android/res/values-it/strings.xml
                  android/res/values-ja/strings.xml
                  android/res/values-ms/strings.xml
                  android/res/values-nb/strings.xml
                  android/res/values-nl/strings.xml
                  android/res/values-pl/strings.xml
                  android/res/values-pt-rBR/strings.xml
                  android/res/values-ro/strings.xml
                  android/res/values-rs/strings.xml
                  android/res/values-ru/strings.xml
                  android/res/values-zh-rCN/strings.xml
                  android/res/values-zh-rTW/strings.xml
                  android/src/org/kde/necessitas/ministro/IMinistro.aidl
                  android/src/org/kde/necessitas/ministro/IMinistroCallback.aidl
                  android/src/org/qtproject/qt5/android/bindings/QtActivity.java
                  android/src/org/qtproject/qt5/android/bindings/QtApplication.java
                  android/version.xml

                  RESOURCES +=
                  res.qrc
                  @

                  My main.cpp:

                  @
                  #include <QApplication>
                  #include <QtQml/QQmlEngine>
                  #include <QtQuick/QQuickView>

                  int main(int argc, char *argv[]){
                  QApplication app(argc, argv);
                  QQuickView view;
                  //Also I try this path: qrc:/QtState.qml
                  view.setSource(QUrl("qrc:///QtState.qml"));
                  view.show();

                  return app.exec();
                  

                  }
                  @

                  My qrc-file:

                  @
                  <RCC>
                  <qresource prefix="/">
                  <file>QtState.qml</file>
                  </qresource>
                  </RCC>
                  @

                  1 Reply Last reply
                  0
                  • raven-worxR Offline
                    raven-worxR Offline
                    raven-worx
                    Moderators
                    wrote on last edited by
                    #9

                    i can't find an error at the first glance.

                    You can make sure that the QtState.qml file gets found by Qt:
                    @
                    qDebug() << "QML file exists?" << QFile(":/QtState.qml").exists();
                    @

                    If true is returned you can go and "debug the QML file":http://qt-project.org/doc/qt-5.0/qtquick/qtquick-debugging.html itself. This is also possible out of QtCreator on remote devices.

                    This may also be interesting for you: set the following environment variable to debug the imports of QML types: QML_IMPORT_TRACE=1

                    --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                    If you have a question please use the forum so others can benefit from the solution in the future

                    1 Reply Last reply
                    0
                    • F Offline
                      F Offline
                      fant
                      wrote on last edited by
                      #10

                      Thank you.
                      I will try it in the next days. :)

                      1 Reply Last reply
                      0

                      • Login

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