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. Launch a second view on a pushed button
Qt 6.11 is out! See what's new in the release blog

Launch a second view on a pushed button

Scheduled Pinned Locked Moved Solved General and Desktop
27 Posts 3 Posters 9.6k 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 Lucian

    Something is wrong.
    It say : "status sig: false"
    So the signal is not generated.

    Also say:
    QObject::connect: No such signal QQuickView::statusChanged()

    mrjjM Offline
    mrjjM Offline
    mrjj
    Lifetime Qt Champion
    wrote on last edited by mrjj
    #16

    @Lucian
    ahh sorry.
    Didnt check the docs. ( shame on me)

    its just missing the parameter.

    void QQuickView::statusChanged(QQuickView::Status status)

    so its
    QObject::connect(view,SIGNAL(statusChanged(QQuickView::Status) ),this, SLOT(startProcess(QQuickView::Status) ) );

    NOte. only Type is added. NOT the paramtername

    and u need/could to change slot too

    void Process::startProcess( QQuickView::Status thesatus) {
    so here u can actually see if its ready etc.

    but u dont need to use the status :)

    1 Reply Last reply
    0
    • L Lucian

      Something is wrong.
      It say : "status sig: false"
      So the signal is not generated.

      Also say:
      QObject::connect: No such signal QQuickView::statusChanged()

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #17

      @Lucian
      Please check documentation: http://doc.qt.io/qt-5/qquickview.html#statusChanged
      The signal has a parameter, so it should be:

      qDebug() << "status sig:" << QObject::connect(view,SIGNAL(statusChanged(QQuickView::Status) ),this, SLOT(startProcess() ) );
      

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • L Offline
        L Offline
        Lucian
        wrote on last edited by Lucian
        #18

        Thanks @mrjj , @jsulm
        Now it's better.
        "status sig: true"

        But the startProcess() still isn't call yet.
        The message from slot is not printed and the calc.exe doesn't show up, but at lest the status from QQuickView is changed.

        jsulmJ 1 Reply Last reply
        0
        • L Lucian

          Thanks @mrjj , @jsulm
          Now it's better.
          "status sig: true"

          But the startProcess() still isn't call yet.
          The message from slot is not printed and the calc.exe doesn't show up, but at lest the status from QQuickView is changed.

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #19

          @Lucian Try to connect first:

          void Process::run() {
              QObject::connect(view,SIGNAL(view::statusChanged),this, SLOT(Process::startProcess()));
              view->setSource(QUrl("qrc:/loading.qml"));
              view->setResizeMode(QQuickView::SizeRootObjectToView);
              view->show();
          }

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • L Offline
            L Offline
            Lucian
            wrote on last edited by
            #20

            Yes @jsulm .
            It work but this doesn't solve my problem.
            I try to connect status change with startProcess because the progress bar (loading.qml) was block by waitForFinish(-1).
            Now is happening the same.
            The signal and the slot are called in the right order but also loading.qml doesn't popup until i close the calc.exe.

            jsulmJ 1 Reply Last reply
            0
            • L Lucian

              Yes @jsulm .
              It work but this doesn't solve my problem.
              I try to connect status change with startProcess because the progress bar (loading.qml) was block by waitForFinish(-1).
              Now is happening the same.
              The signal and the slot are called in the right order but also loading.qml doesn't popup until i close the calc.exe.

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #21

              @Lucian Why do you wait for the process to finish?

              this->proc->waitForFinished(-1);
              

              Are you aware that this call blocks the event loop (so your app is blocked)?

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • L Offline
                L Offline
                Lucian
                wrote on last edited by Lucian
                #22

                Yes @jsulm .
                I need to do that because the process what will be launch will create a txt file. This file will be use farder so i need to be sore the process has finished his job and has created the txt.

                jsulmJ 1 Reply Last reply
                0
                • L Lucian

                  Yes @jsulm .
                  I need to do that because the process what will be launch will create a txt file. This file will be use farder so i need to be sore the process has finished his job and has created the txt.

                  jsulmJ Offline
                  jsulmJ Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on last edited by jsulm
                  #23

                  @Lucian No need to wait for this! Just connect to http://doc.qt.io/qt-5/qprocess.html#finished signal - when it is called the process has finished...
                  Qt is an asynchronous framework - you should adapt to asynchronous programming.

                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0
                  • L Offline
                    L Offline
                    Lucian
                    wrote on last edited by
                    #24

                    But how will wait my application to create the txt file ? Because after the process is finished i want to read from that .txt file created by him and if i read before creation the application will fail.
                    So i need to connect the finish signal from QProcess with a slot that make the read from .txt file? :D

                    jsulmJ 1 Reply Last reply
                    0
                    • L Lucian

                      But how will wait my application to create the txt file ? Because after the process is finished i want to read from that .txt file created by him and if i read before creation the application will fail.
                      So i need to connect the finish signal from QProcess with a slot that make the read from .txt file? :D

                      jsulmJ Offline
                      jsulmJ Offline
                      jsulm
                      Lifetime Qt Champion
                      wrote on last edited by
                      #25

                      @Lucian Yes, you simply connect a slot to that signal and do what you want with that file in this slot.

                      https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Reply Last reply
                      0
                      • L Offline
                        L Offline
                        Lucian
                        wrote on last edited by
                        #26

                        I have made some changes and now look like this:

                        void Process::startProcess()
                        {
                            qDebug() << "startProcess called";
                            this->proc->start("C:\\Windows\\System32\\calc.exe", QIODevice::ReadWrite);
                            qDebug() << "connect status :" << QObject::connect(proc,SIGNAL(QProcess::finished()),this, SLOT(addData()));
                        }
                        

                        And the slot:

                        void Process::addData()
                        {
                            qDebug() << "addData call:";
                            SomeClasss c;    
                            c.read();
                        }
                        

                        The problem is again with type of the signal:
                        *QObject::connect: No such signal QProcess::QProcess::finished()

                        From documentation (Qt doc) doesn't seems to be something wrong.

                        1 Reply Last reply
                        0
                        • L Offline
                          L Offline
                          Lucian
                          wrote on last edited by Lucian
                          #27

                          I have solved the problem like this:

                              qDebug() << "connect status :" << QObject::connect(proc,SIGNAL(finished(int, QProcess::ExitStatus)),this, SLOT(addData()));
                          

                          I will mark this as Solved.
                          Thank you for your help @jsulm , @mrjj .

                          1 Reply Last reply
                          1

                          • Login

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