Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. How to inactivate qdialog
QtWS25 Last Chance

How to inactivate qdialog

Scheduled Pinned Locked Moved Mobile and Embedded
10 Posts 3 Posters 4.2k Views
  • 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.
  • G Offline
    G Offline
    gosk
    wrote on last edited by
    #1

    Hi,

    In my program I have 2 qdialogs. In first dialog when a certain push button is clicked I want to pop up the second dialog but at the same time I want to run the rest of the code in the first dialog.
    I did something like this in my first dialog box.

    @
    // code1
    Dialog2 *d11=new Dialog2();
    d11->exec();
    // code2
    @

    But when it is running the 2nd dialog appears and the code beyond the originating of 2nd dialog (code2) doesn't run. What should I do in order to pop up 2nd dialog and be inactive during the execution?

    1 Reply Last reply
    0
    • I Offline
      I Offline
      Iktwo
      wrote on last edited by
      #2

      when you run exec() it wait's for you to close (accept, cancel or actually close) the dialog, so maybe you could run your code before exec() or use show() instead of exec()

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

        I think you are looking for the open() or show() methods instead, depending if you want to have the second window behave like a modal or a non-modal window.

        1 Reply Last reply
        0
        • G Offline
          G Offline
          gosk
          wrote on last edited by
          #4

          Hi,

          I tried in that way using show(). But then the 2nd dialog appears after executing the entire code. (after executing code2)

          1 Reply Last reply
          0
          • G Offline
            G Offline
            gosk
            wrote on last edited by
            #5

            open() also doesnt seem to be working

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

              Yes, that is true. The point is, that in order for Qt to be able to handle drawing windows, it needs the eventloop to run. And while your code is running, the eventloop is not. Could you tell us a bit more on what you want to achieve exactly? Are you running some long operations that you want to show progress on, perhaps?

              1 Reply Last reply
              0
              • G Offline
                G Offline
                gosk
                wrote on last edited by
                #7

                Hi Andre,

                Actually I want to copy a selected file from one location to another. I am using qfilesystem for file navigation and once a file is selected and click the copy button the content must be copied.
                In this program up to the code1 I am doing file navigation and then the dialog2 must be appeared. then I execute copy command (command2)using qprocess:execute(cp,..).after the copying is completed the 2nd dialog must be closed. I am doing it using d11.close().

                thank you.

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

                  In that case, I have two suggestions that you can think about:

                  Use the non-static methods of QProcess instead, and use the asynchronous methods (that is: connect to the finished() and other signals instead of using the waitFor* methods). That way, you will return to the eventloop as needed and everything will go smoothly. You can use the QProcess::finished() signal to close the second dialog.

                  Implement your own file copying. This one is more tricky, but allows for greater control. You still need to make sure to return to the eventloop regulary during the copy process, either by doing the work in chunks or by using one of the multi-threading options.

                  I think method 1 is easiest for now, and probably sufficient for your needs.

                  1 Reply Last reply
                  0
                  • G Offline
                    G Offline
                    gosk
                    wrote on last edited by
                    #9

                    Hi,

                    First of all sorry for delay reply. As you said I did something like following.

                    @
                    //code1
                    Dialog2 *d11=new Dialog2();
                    d11->open();
                    QProcess *myprocess =new QProcess();
                    myprocess->execute("cp", args);
                    connect(myprocess,SIGNAL(finished(int)),d11,SLOT(close1()));
                    @

                    And in my Dialog2, I wrote close1() as follow

                    @
                    close1()
                    {
                    this.close();
                    }
                    @

                    but the second dialog doesn't appear at the beginning of the copy process and also it doesn't close after copletion of the copy process. What I am missing here?

                    thanks a lot.

                    [EDIT: code formatting, please wrap in @-tags, Volker]

                    1 Reply Last reply
                    0
                    • G Offline
                      G Offline
                      gosk
                      wrote on last edited by
                      #10

                      sorry the connect method is as follow.
                      connect(myprcocess,SIGNAL (finished(int)),d11, SLOT (close1()))

                      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