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. how to close the window
Qt 6.11 is out! See what's new in the release blog

how to close the window

Scheduled Pinned Locked Moved Solved General and Desktop
15 Posts 4 Posters 5.0k 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
    victor wang
    wrote on last edited by
    #1

    Hi,
    I'm using qt5.5 on my computer.
    This is the UI that i designed.
    UI

    And when i click the "Burning Test" Button it will going to this page like below.
    page

    Then it will execute the .sh file by using QProcess in QT program.
    It will show this windows out.
    Windows

    When i clicked stop button (where i show you in the second picture) i will delete all the process and Thread.
    This is my program below.
    program

    But the windows (where i show you in the third picture) will not closed when i clicked the stop button.

    Did i miss anything?
    Please help!

    1 Reply Last reply
    0
    • Vinod KuntojiV Offline
      Vinod KuntojiV Offline
      Vinod Kuntoji
      wrote on last edited by Vinod Kuntoji
      #2

      @victor-wang,

      First you should close the thread and then close the window.

      if(cpuInfoThread->isRunning())
      {
      cpuInfoThread->quit();
      cpuInfoThread->wait(2);
      cpuInfoThread->terminate();
      cpuInfoThread->wait();
      }
      window->close()

      C++, Qt, Qt Quick Developer,
      PthinkS, Bangalore

      V 1 Reply Last reply
      3
      • Vinod KuntojiV Vinod Kuntoji

        @victor-wang,

        First you should close the thread and then close the window.

        if(cpuInfoThread->isRunning())
        {
        cpuInfoThread->quit();
        cpuInfoThread->wait(2);
        cpuInfoThread->terminate();
        cpuInfoThread->wait();
        }
        window->close()

        V Offline
        V Offline
        victor wang
        wrote on last edited by
        #3

        @Vinod-Kuntoji
        But i didnt using thread to open the window.
        i'm using thread on other process.

        1 Reply Last reply
        0
        • Vinod KuntojiV Offline
          Vinod KuntojiV Offline
          Vinod Kuntoji
          wrote on last edited by
          #4

          @victor-wang ,

          Disconnect the process, then kill the process, it will close the console window.

          C++, Qt, Qt Quick Developer,
          PthinkS, Bangalore

          V 1 Reply Last reply
          1
          • Vinod KuntojiV Vinod Kuntoji

            @victor-wang ,

            Disconnect the process, then kill the process, it will close the console window.

            V Offline
            V Offline
            victor wang
            wrote on last edited by
            #5

            @Vinod-Kuntoji
            I'm using both process->close(); and process->terminate(); none of those can work as i expect.

            What else should i so ?

            jsulmJ 1 Reply Last reply
            0
            • Vinod KuntojiV Offline
              Vinod KuntojiV Offline
              Vinod Kuntoji
              wrote on last edited by
              #6

              @victor-wang ,

              Allocate the process in stack instead of heap

              C++, Qt, Qt Quick Developer,
              PthinkS, Bangalore

              1 Reply Last reply
              1
              • V victor wang

                @Vinod-Kuntoji
                I'm using both process->close(); and process->terminate(); none of those can work as i expect.

                What else should i so ?

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

                @victor-wang Did you try http://doc.qt.io/qt-5/qprocess.html#kill ?

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

                V 1 Reply Last reply
                4
                • jsulmJ jsulm

                  @victor-wang Did you try http://doc.qt.io/qt-5/qprocess.html#kill ?

                  V Offline
                  V Offline
                  victor wang
                  wrote on last edited by
                  #8

                  @jsulm
                  Yes, I did try this one.
                  But the window still not close either.

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

                    Hi,

                    Can you share the code used to start that application ?

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

                    V 1 Reply Last reply
                    0
                    • SGaistS SGaist

                      Hi,

                      Can you share the code used to start that application ?

                      V Offline
                      V Offline
                      victor wang
                      wrote on last edited by
                      #10

                      @SGaist
                      Sure, this is how i start my application.

                      /usr/share/qt5/examples/qt3d/anaglyph-rendering/anaglyph-rendering -platform wayland
                      

                      I save it as a shell script and using QProcess to execute this .sh file.

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

                        Why are you using a shell script and not Process directly ?

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

                        V 3 Replies Last reply
                        0
                        • SGaistS SGaist

                          Why are you using a shell script and not Process directly ?

                          V Offline
                          V Offline
                          victor wang
                          wrote on last edited by
                          #12

                          @SGaist
                          It's just because someone had done it before.
                          And i just using it by convenient.
                          Is that the reason why i can't close the window?

                          1 Reply Last reply
                          0
                          • SGaistS SGaist

                            Why are you using a shell script and not Process directly ?

                            V Offline
                            V Offline
                            victor wang
                            wrote on last edited by
                            #13

                            @SGaist
                            You are right!
                            I try to using Process instead of shell script and it works as my expect!
                            Thanks a lot!

                            1 Reply Last reply
                            1
                            • SGaistS SGaist

                              Why are you using a shell script and not Process directly ?

                              V Offline
                              V Offline
                              victor wang
                              wrote on last edited by
                              #14

                              @SGaist
                              I still have a question.
                              Why i have to do it directly from Process but not shell script for instead?
                              I can't understand.
                              Could you tell me the difference between those two cases?

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

                                Number of layers: you are starting a shell that is starting an application so you'll be "communicating" with that shell but not with the application that was started with that shell.

                                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
                                1

                                • Login

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