Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. QML C++ application runs much slower than pure QML

QML C++ application runs much slower than pure QML

Scheduled Pinned Locked Moved QML and Qt Quick
8 Posts 5 Posters 6.8k 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.
  • L Offline
    L Offline
    longWorm
    wrote on last edited by
    #1

    Hi everyone.

    I'm writing small game in qml. When i run it in qmlviewer everything works fine, application uses 10-15% CPU. When i create QtQuick project and run application with QmlApplicationViewer C++ class it runs much slower, there is about 70-80 % CPU usage.

    Is it normal? Can i deploy pure QML application?
    Can I make package or bin file from my app without writing C++ code?

    Thanks everyone.

    1 Reply Last reply
    0
    • C Offline
      C Offline
      Chuck Gao
      wrote on last edited by
      #2

      It's weird. Since everything is works properly for me, can you paste your env? Desktop ? Mobile ?

      Chuck

      1 Reply Last reply
      0
      • A Offline
        A Offline
        andre
        wrote on last edited by
        #3

        Very strange, because the QML viewer app does not much more than use the same class. Did you try setting a QGLWidget as your viewport widget?

        1 Reply Last reply
        0
        • M Offline
          M Offline
          MichK
          wrote on last edited by
          #4

          You may try to use QML Profiler in Qt Creator. It should give you some clue.

          1 Reply Last reply
          0
          • L Offline
            L Offline
            longWorm
            wrote on last edited by
            #5

            Thank's everyone for replies!
            "Here's the link to my project. Main file is _arca.qml.":http://www.filefactory.com/file/c496a01/n/_arca.rar

            1. I ran it with qmlviewer ("qmlviewer _arca.qml" in terminal)
            2. I made QtQuick project. My main.cpp:
              @
              #include <QtGui/QApplication>
              #include "qmlapplicationviewer.h"

            Q_DECL_EXPORT int main(int argc, char *argv[])
            {
            QScopedPointer<QApplication> app(createApplication(argc, argv));

            QmlApplicationViewer viewer;
            viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto);
            viewer.setMainQmlFile&#40;QLatin1String("_arca.qml"&#41;);
            viewer.showExpanded();
            return app->exec&#40;&#41;;
            

            }
            @
            Now i understood, that it's bad idea to use javascript in C++ application so i'm rewriting all logic in C++.
            But the problem wasn't solved.

            1 Reply Last reply
            0
            • L Offline
              L Offline
              longWorm
              wrote on last edited by
              #6

              And i forgot to say that its desktop configuration.

              I'll try to use QGLWidget and write about results

              1 Reply Last reply
              0
              • O Offline
                O Offline
                outdoor_guy
                wrote on last edited by
                #7

                Have you tried
                @ QApplication::setGraphicsSystem("raster");@

                at the beginning of the main (I would say in Line 7 or so)

                For me, this makes the application much faster

                1 Reply Last reply
                0
                • L Offline
                  L Offline
                  longWorm
                  wrote on last edited by
                  #8

                  Yes, i already tried it before, but application is still very slow.
                  Can somebody give advice how to make an explosion animation?
                  I tried two variant but both are too slow.

                  1. Dynamically create some objects and make them move to different corners of screen
                  2. Use Particles qml object (burst method)
                    [quote author="outdoor_guy" date="1331547299"]Have you tried
                    @ QApplication::setGraphicsSystem("raster");@

                  at the beginning of the main (I would say in Line 7 or so)

                  For me, this makes the application much faster[/quote]

                  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