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 gui and nogui mode[solved]
Forum Updated to NodeBB v4.3 + New Features

Qml gui and nogui mode[solved]

Scheduled Pinned Locked Moved QML and Qt Quick
14 Posts 2 Posters 4.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.
  • V Offline
    V Offline
    Vardan95
    wrote on last edited by
    #3

    [quote author="SGaist" date="1408743674"]Hi and welcome to devnet,

    The most simple way is to create a default qml application and copy it's main content (except the QApplication creation) in place of // start GUI version[/quote]

    You mean kind of this?
    @QScopedPointer<QCoreApplication> app(createApplication(argc, argv));
    if (qobject_cast<QApplication *>(app.data())) {
    qmlRegisterType<CoreAdapter>("conv.core", 1, 0, "CoreAdapter");
    QQmlApplicationEngine engine;
    engine.load(QUrl(QStringLiteral("qrc:///main.qml")));
    } else {
    // start non-GUI version...
    }
    return app->exec();@

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #4

      Did you mean in gui mode ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • V Offline
        V Offline
        Vardan95
        wrote on last edited by
        #5

        Unfortunately, I wrote wrong,sorry for it. but this code does not work

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #6

          You'll have to be more specific. "Does not work" doesn't really say what is currently happening. What should you be getting ? What are you getting ? What parameters are you passing to your application ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • V Offline
            V Offline
            Vardan95
            wrote on last edited by
            #7

            ok,in cmd I wrote app-name.exe -no-gui,program started,but not showed,it's just ran in process(Task Manager).The same with -gui parameter

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #8

              -no-gui implies that there will be no gui so there's nothing to be shown.

              As for a "gui" run, your QQmlApplicationEngine goes out of scope before you reach app->exec() so nothing will be shown either.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • V Offline
                V Offline
                Vardan95
                wrote on last edited by
                #9

                [quote author="SGaist" date="1408905527"]-no-gui implies that there will be no gui so there's nothing to be shown.

                As for a "gui" run, your QQmlApplicationEngine goes out of scope before you reach app->exec() so nothing will be shown either.[/quote]

                but for nu-gui I have function,and I want to execute that function(it's a simple c++ console app, wich workes for non qml version)

                and for "gui" I understand that,and I apologise for bad code :),but the result is same in this case too
                @QScopedPointer<QCoreApplication> app(createApplication(argc, argv));
                if (qobject_cast<QApplication *>(app.data())) {
                qmlRegisterType<CoreAdapter>("conv.core", 1, 0, "CoreAdapter");
                QQmlApplicationEngine engine;
                engine.load(QUrl(QStringLiteral("qrc:///main.qml")));
                return app->exec();
                } else {
                // start non-GUI version...
                return app->exec();
                }@

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #10

                  If you replace your main content with

                  @
                  QApplication app(argc, argv);
                  qmlRegisterType<CoreAdapter>("conv.core", 1, 0, "CoreAdapter");
                  QQmlApplicationEngine engine;
                  engine.load(QUrl(QStringLiteral("qrc:///main.qml")));
                  return app.exec();
                  @

                  is it working ? If not, then first ensure you have it working before adding your gui/non-gui code

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0
                  • V Offline
                    V Offline
                    Vardan95
                    wrote on last edited by
                    #11

                    It workes only from Qt Creator,but from debug/release folders it's doesn't run
                    I put some .dll files into that folder,but it didn't help.I get this error
                    !http://s3.postimg.org/hwu6q9jer/qtprob.jpg(Error)!
                    and dll files !http://s3.postimg.org/werdy9apv/dll_s.jpg(dll)!

                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #12

                      If you want to run it in the explorer then you need to follow the same step as if you were deploying it on another computer.

                      Follow this fine "wiki entry":http://qt-project.org/wiki/Deploy_an_Application_on_Windows

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Reply Last reply
                      0
                      • V Offline
                        V Offline
                        Vardan95
                        wrote on last edited by
                        #13

                        Thanks very much,you really helped me :)

                        1 Reply Last reply
                        0
                        • SGaistS Offline
                          SGaistS Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on last edited by
                          #14

                          You're welcome !

                          Since you have it running now, please update the thread title prepending [solved] so that other forum users may know a solution has been found :)

                          Interested in AI ? www.idiap.ch
                          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                          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