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. Independence between dialog and application windows

Independence between dialog and application windows

Scheduled Pinned Locked Moved General and Desktop
14 Posts 6 Posters 6.1k 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.
  • T Offline
    T Offline
    tobias.hunger
    wrote on last edited by
    #4

    http://doc.qt.nokia.com/latest/qdialog.html has lots of information about dialogs in Qt. The section on modal dialogs is of special interest to you.

    1 Reply Last reply
    0
    • R Offline
      R Offline
      RSousa
      wrote on last edited by
      #5

      Hi,

      Thank you for your answers.:)

      In fact, I was using exec(). :)
      The dialog window is non-modal.
      I've changed to show() but the dialog window opens and suddenly closes...
      I'm calling this dialog window from a menu.

      Could you help me.

      Many thanks!

      All the best

      Ricardo Sousa

      1 Reply Last reply
      0
      • G Offline
        G Offline
        giesbert
        wrote on last edited by
        #6

        Please show us the code where you show your dialog.
        I'm sure, it's pretty easy.
        Perhaps, the dialog is creatot on the stack and not by new?

        Nokia Certified Qt Specialist.
        Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

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

          If it suddenly closes, perhaps you are creating your item on the stack instead of on the heap?

          1 Reply Last reply
          0
          • I Offline
            I Offline
            ivan.todorovich
            wrote on last edited by
            #8

            [quote author="Andre" date="1300904949"]If it suddenly closes, perhaps you are creating your item on the stack instead of on the heap?[/quote]

            That's exactly my thought

            o_o Sorry for my rusted english.

            1 Reply Last reply
            0
            • R Offline
              R Offline
              RSousa
              wrote on last edited by
              #9

              This is the code....
              @
              //---
              connect(ui->actionSpectrogram,SIGNAL(toggled(bool)),this,SLOT(VerMenuSpectrogram()));

              //------
              void MainWindow::VerMenuSpectrogram(){

              Ui_Spectrogram *ui_Spect;
              ui_Spect= new Ui_Spectrogram();
              QDialog D;
              ui_Spect->setupUi(&D);
              D.show();

              }
              @

              I really thank you!

              Ricardo Sousa

              Edit: Fixed code layout. Please use the @ tags; Andre

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

                My diagnoses was correct. You are creating your dialog on the stack instead of on the heap.

                1 Reply Last reply
                0
                • R Offline
                  R Offline
                  RSousa
                  wrote on last edited by
                  #11

                  How do you know that...?:)

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

                    [quote author="RSousa" date="1301053052"]How do you know that...?:)[/quote]

                    I read the piece of code you posted, of course :-)

                    Look at line 10 of the snippet you just posted. What happens there? You create a variable called D on the stack. What happens once your code reaches line 13? That variable goes out of scope, and gets removed from the stack again. C++, the nice language it is, thoughtfully calls the destructor for the class in question for you (QDialog). Boom! Your dialog is gone again.

                    1 Reply Last reply
                    0
                    • G Offline
                      G Offline
                      goetz
                      wrote on last edited by
                      #13

                      Because he knows the difference between stack and heap allocation. You obviously do not, so time to get some good C++ introduction and learn the basics.

                      Some keywords for google:

                      • stack allocation
                      • heap allocation
                      • scope of variable

                      http://www.catb.org/~esr/faqs/smart-questions.html

                      1 Reply Last reply
                      0
                      • R Offline
                        R Offline
                        RSousa
                        wrote on last edited by
                        #14

                        Now I can see.... it works now.... I'm embarassed .... :)

                        I need vacations.....

                        I really thank you for all!

                        All the best!!!

                        Ricardo Sousa

                        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