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. Including files
Forum Updated to NodeBB v4.3 + New Features

Including files

Scheduled Pinned Locked Moved Unsolved General and Desktop
15 Posts 3 Posters 967 Views 2 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.
  • P Offline
    P Offline
    programthis
    wrote on last edited by programthis
    #3

    @Pl45m4 said in Including files:

    @programthis said in Including files:

    But class B still lacks it's definition so I can't reference an object of that class and connect to the slot.

    How does class B look like? Does it have a slot called on_ON_clicked?

    Where do you create the instance of B? In A's c'tor?

    First of all thanks for the reply!

    Class B indeed has a private slot called on_ON_clicked
    The instance of B is created in the private section of the "A.h"
    By 'created' I mean declared.

    I've created this snippet, maybe it will be easier to see:
    https://gitlab.com/-/snippets/2106333

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

      Hi and welcome to devnet,

      How do you know that the processing is done ?

      From a quick look at your code, you might not even need that signal to enable your other widget again.

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

      P 1 Reply Last reply
      1
      • SGaistS SGaist

        Hi and welcome to devnet,

        How do you know that the processing is done ?

        From a quick look at your code, you might not even need that signal to enable your other widget again.

        P Offline
        P Offline
        programthis
        wrote on last edited by programthis
        #5

        @SGaist said in Including files:

        Hi and welcome to devnet,

        How do you know that the processing is done ?

        From a quick look at your code, you might not even need that signal to enable your other widget again.

        I used the std::this_thread::sleep_for(std::chrono::seconds(40)); function for the time it takes the processing to complete.
        The widget opens via script command but it's on 'OFF' mode and I want to turn it 'ON' so that's why I want to signal.

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

          Using sleep is a bad idea because you are going to block the event loop.

          So how is the processing started ?

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

          P 1 Reply Last reply
          1
          • SGaistS SGaist

            Using sleep is a bad idea because you are going to block the event loop.

            So how is the processing started ?

            P Offline
            P Offline
            programthis
            wrote on last edited by
            #7

            @SGaist said in Including files:

            Using sleep is a bad idea because you are going to block the event loop.

            I am using it precisely to block the event loop so I can call script commands that run different programs in order without overlapping each other.

            So how is the processing started ?

            Also a program that gets called through a script command. Once it finishes, it in itself calls SYSTEM_START again through a script command but like I said, SYSTEM_START is called in 'OFF' mode and I want it to launch and then to turn it back on so the system resumes normal function.

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

              Then you have an architecture issue.

              If you have several scripts to call then make a list of them and use QProcess to call them one after the other leveraging its asynchronous nature.

              You will then be able to better manage your widgets.

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

              P 1 Reply Last reply
              3
              • SGaistS SGaist

                Then you have an architecture issue.

                If you have several scripts to call then make a list of them and use QProcess to call them one after the other leveraging its asynchronous nature.

                You will then be able to better manage your widgets.

                P Offline
                P Offline
                programthis
                wrote on last edited by
                #9

                @SGaist said in Including files:

                Then you have an architecture issue.

                If you have several scripts to call then make a list of them and use QProcess to call them one after the other leveraging its asynchronous nature.

                You will then be able to better manage your widgets.

                Alright, looking into it now.
                Just for reference, this is the .cpp file:
                https://gitlab.com/-/snippets/2106380

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

                  I confirm my original diagnostic.

                  No need for that intermediate signal and you definitely want to use QProcess.

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

                  P 2 Replies Last reply
                  1
                  • SGaistS SGaist

                    I confirm my original diagnostic.

                    No need for that intermediate signal and you definitely want to use QProcess.

                    P Offline
                    P Offline
                    programthis
                    wrote on last edited by
                    #11

                    @SGaist said in Including files:

                    I confirm my original diagnostic.

                    No need for that intermediate signal and you definitely want to use QProcess.

                    Alright, I'm looking in to QProccess and re writing the code

                    1 Reply Last reply
                    0
                    • SGaistS SGaist

                      I confirm my original diagnostic.

                      No need for that intermediate signal and you definitely want to use QProcess.

                      P Offline
                      P Offline
                      programthis
                      wrote on last edited by
                      #12

                      @SGaist
                      How do you actually let QProcess know when to wait not only for the script to run, but for the program that the script calls as well?

                      QProcess *q1 = new QProcess(this);
                          q1->execute("/bin/sh", QStringList() << "/full/path/Run_GUI_Kill.sh &");
                          q1->waitForFinished();
                          q1->execute("/bin/sh", QStringList() << "/full/path/SYSTEM_START_Kill.sh &");
                          q1->waitForFinished();
                          q1->execute("/bin/sh", QStringList() << "/full/path/PROCESS_ALGORITHM.sh &");
                          q1->waitForFinished();
                          q1->execute("/bin/sh", QStringList() << "/full/path/Run_GUI.sh &");
                          q1->waitForFinished();
                      

                      If I run this, it will call all the programs without actually waiting for everything to finish up before starting the next one in order, including the process algorithm that needs time to run.

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

                        First, remove that & from your script calls.

                        Next, use QProcess::finished to get the information that your script is done. You should also check the error just in case something goes wrong.

                        As already suggested, use a list of all your commands and pick the next one each time the previous script ended successfully.

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

                        P 1 Reply Last reply
                        1
                        • SGaistS SGaist

                          First, remove that & from your script calls.

                          Next, use QProcess::finished to get the information that your script is done. You should also check the error just in case something goes wrong.

                          As already suggested, use a list of all your commands and pick the next one each time the previous script ended successfully.

                          P Offline
                          P Offline
                          programthis
                          wrote on last edited by programthis
                          #14

                          @SGaist said in Including files:

                          First, remove that & from your script calls.

                          Next, use QProcess::finished to get the information that your script is done. You should also check the error just in case something goes wrong.

                          As already suggested, use a list of all your commands and pick the next one each time the previous script ended successfully.

                          But that is it, the script finishes in less than a second. It launches a compiled program or process which I don't know when it ends(or starts, for that matter). That's why I used the sleep function in the first place.

                          How would you use the QProcess::finished function to determine that a system process has finished?

                          Here is my take on it: https://gitlab.com/-/snippets/2106599

                          Note that this isn't even why I started the thread. I had a problem with calling a class instance from a different project.
                          The sleep function was working perfectly fine.. I don't know why I even need this QProccess stuff...

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

                            Because using sleep to ensure your process is done is not the right way to ensure it has run and that it happened without error.

                            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