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. Child dialog in a mail dialog.

Child dialog in a mail dialog.

Scheduled Pinned Locked Moved General and Desktop
19 Posts 5 Posters 7.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.
  • D Offline
    D Offline
    deepak_smcet
    wrote on last edited by
    #1

    hello,

    i am trying to create a child dialog in a main dialog. i am able to see and move it to main dialog geometry. using following code.

    In main constructor:
    @m_pChildDlg = new ClildDialog(this);
    m_pChildDlg->setModal(false);
    m_pChildDlg->setWindowFlags(Qt::Popup);@

    In the button handler
    @void MainDialog::DisplayDialog()
    {
    m_pChildDlg->show();
    m_QPoint p(this->window()->geometry().topLeft());
    m_pChildDlg->move(p);
    }
    @
    but when i click on the parent dialog, it disapears. i have to click on displaydialog button to show it again. what i want to achieve is i could display multiple child dialogs one at time when i click button on mail dialog.

    could someone tell me how to do it?
    regards
    D

    1 Reply Last reply
    0
    • F Offline
      F Offline
      fluca1978
      wrote on last edited by
      #2

      If you want to display one dialog at a time you have to do:

      @m_pChildDlg->setModal(true);@

      1 Reply Last reply
      0
      • M Offline
        M Offline
        McgowanM
        wrote on last edited by
        #3

        m_pChildDlg->setModal(false)

        I'm extremely sorry, but I don't get this.
        Is it because I'm a grown up? Or it's because I'm not smart enough? :D

        [url=http://freemkvplayer.net/]mkv player[/url]

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

          Are you looking for "MDI":http://developer.qt.nokia.com/doc/qt-4.7/qmdiarea.html per chance?

          1 Reply Last reply
          0
          • D Offline
            D Offline
            deepak_smcet
            wrote on last edited by
            #5

            thanks fluca1978,

            but i don't want to make it modal. what i want is to stick this dialog with main dialog. just like button, label does. a child stick to maindialog which i could hide and unhide.

            regards
            D

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

              Could you perhaps post a sketch of what you want to achieve?

              1 Reply Last reply
              0
              • F Offline
                F Offline
                fluca1978
                wrote on last edited by
                #7

                [quote author="deepak_smcet" date="1323160391"]thanks fluca1978,

                but i don't want to make it modal. what i want is to stick this dialog with main dialog. just like button, label does. a child stick to maindialog which i could hide and unhide.

                regards
                D[/quote]

                So you need a singleton dialog. What you have to do is something like this:

                @
                if( m_pChildDlg == NULL ){
                m_pChildDlg = new ClildDialog(this);
                m_pChildDlg->setModal(false);
                m_pChildDlg->setWindowFlags(Qt::Popup);
                }
                else
                m_pChildDlg->setVisible( true );
                @

                of course the pointer must be initialized to NULL at the beginning. So in this way you will make a single instance of the window available during the program, which is created the first time it is needed and is simply re-shown when called back again. There are other techniques to make singleton in a more elegant way, but this should suffice.

                1 Reply Last reply
                0
                • D Offline
                  D Offline
                  deepak_smcet
                  wrote on last edited by
                  #8

                  hello,

                  i am sorry if i am not able to communicate my question to you clearly. but thanks for you input.

                  there is a example here "I:\Qt\4.7.4\examples\dialogs\configdialog". it makes use of QListWidget and QStackedWidget class. in the same way i want to have few buttons in the left side. and when i click on the different button i should display a different dialog(but the dialog should be embedded into the mail dialog just like in the example). the example make user of Qwidget class to create some demo pages.

                  since i am from MFC backgroud, all you have to do is to create the modalless dialog on Oninitiazedlg() and set the parent to the parent dialog. and then child dialog will be shown into the main dialog.

                  is there any way to upload a few kb source?
                  here is the MFC source:

                  @
                  BOOL CChildDialogDlg::OnInitDialog()
                  {
                  CDialog::OnInitDialog();

                  m_child.Create(CChildOne::IDD, this);
                  }

                  void CChildDialogDlg::OnBnClickedStShow()
                  {
                  // TODO: Add your control notification handler code here
                  static bool bShow = true;

                  if(bShow)
                  m_child.ShowWindow(SW_SHOW);
                  else
                  m_child.ShowWindow(SW_HIDE);

                  bShow = !bShow;

                  }
                  @

                  the property is set to 'child' in the dialog editor of MFC.

                  regards
                  D

                  1 Reply Last reply
                  0
                  • F Offline
                    F Offline
                    fluca1978
                    wrote on last edited by
                    #9

                    So you are not searching to display a dialog window, you are trying to display different widgets depending on the user selection on the left panel bar. There are different ways to achieve it, one it could be to use a stack layout. As you mentioned, take the config dialog example and implement it in a similar way. Just create a set of top level widgets that are containers for your right side widgets and display the top level containers when needed.

                    1 Reply Last reply
                    0
                    • D Offline
                      D Offline
                      deepak_smcet
                      wrote on last edited by
                      #10

                      is there any other way to do it except using stacked containers? any simpler way? the reason i am using dialog is because i could make use to editor to place other items on it. but in the example, all the other controls are created dynamically.

                      regards
                      D

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

                        Using a [[doc:QStackedWidget]] is really quite simple. You can do it completely using Qt Designer even, without writing code. No need to create dynamic controls.

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

                          @
                          m_pChildDlg->setWindowFlags(Qt::Popup);
                          @

                          is most likely to cause your trouble. Popups usually go away when they loos focus (what happens by clicking the main window). Just make it a regular window/widget and you're done.

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

                          1 Reply Last reply
                          0
                          • D Offline
                            D Offline
                            deepak_smcet
                            wrote on last edited by
                            #13

                            hello volker,

                            you are right but it did not solve the problem,

                            if i set it to
                            @pChildDlg = new ClildDialog(this);
                            pChildDlg->setModal(false);
                            pChildDlg->setWindowFlags(Qt::Widget);@

                            and then call

                            @ QPoint p(this->window()->geometry().topLeft());
                            pChildDlg->move(p);
                            pChildDlg->show();@

                            the widget is not shown.

                            but if i set it to
                            @ pChildDlg->setWindowFlags(Qt::Window);@

                            the dialog is shown but has border on it, i used the property 'WindowTitleHint' to clear some of those. yes after setting above flag it does not go away, but when i move the main window it does not move with it. i want it to be stick to main window just like button and other dialogs.

                            is there any way to upload small source file here in the post, i dont see such option

                            @Andre,

                            i will try your suggestion soon and update the post soon
                            regards
                            D

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

                              You have a completely independent window with your popup. To move it together with your mainwindow, you need to reimplement moveEvent and move your popup by the same amount as your mainwindow.

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

                              1 Reply Last reply
                              0
                              • D Offline
                                D Offline
                                deepak_smcet
                                wrote on last edited by
                                #15

                                humm,

                                i just a read a post here
                                http://lists.trolltech.com/qt-interest/2002-12/msg01080.html
                                which says that
                                "Dialogs are ALWAYS toplevel widgets and are NEVER children of other widgets. If you specify a parent in a dialog it is only for positional reasions"

                                i think this is my mistake, i am trying to use a dialog as a widget. i mean i am trying to make it children of other dialog.

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

                                  That "positional reason" is only for the initial display of the dialog.

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

                                  1 Reply Last reply
                                  0
                                  • F Offline
                                    F Offline
                                    fluca1978
                                    wrote on last edited by
                                    #17

                                    I'm totally unable to understand what you are trying to achieve...

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

                                      [quote author="fluca1978" date="1323178212"]I'm totally unable to understand what you are trying to achieve...[/quote]

                                      This is how I understood it:

                                      • there should be a non-modal toplevel window (e.g. like a search/replace window of a word processor), so that both the main window and the popup are functional at the same time
                                      • the second window is supposed to move together with the main window in case the latter is moved

                                      The problem was that by using the wrong window flags, the popup was closed when clicking into the main window.

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

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

                                        [quote author="fluca1978" date="1323178212"]I'm totally unable to understand what you are trying to achieve...[/quote]

                                        Hence the request to send a sketch that we can look at...

                                        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