Results 1 to 9 of 9

Thread: QDialog::exec() cereates no modal dialog

  1. #1
    Join Date
    Jan 2006
    Posts
    3
    Qt products
    Qt3
    Platforms
    MacOS X Windows

    Default QDialog::exec() cereates no modal dialog

    Hi,

    in my application I use many different QDialogs and call them via exec() - method. Therefor the user sould not be able to close the main application widget or to use the menu of the main app widget.
    It works for most of the QDialogs, but for one of them it doesn't: main app widget can be closed while this QDialog is open. The only difference to the other dialogs is, that this dialog has many widgets inside (it's a tab widget dialog). I also made an explicitly call to setModal(true) - doesn't work .

    This is how I create the dialog:


    m_pQDlgConfig = new SGenConfigDialog( this, "1" );
    connect( m_pQDlgConfig, SIGNAL(signalUpdateTDMainWindow()), this, SLOT(SlotUpdateXSDTreeView()) );

    m_pQDlgConfig->setModal(true);

    if ( m_pQDlgConfig->exec() == QDialog::Accepted )
    {
    ASSERT("E");
    } else {
    ASSERT("E");
    }

    if ( m_pQDlgConfig )
    {
    delete m_pQDlgConfig;
    m_pQDlgConfig = NULL;
    }

    where SGenConfigDialog is a QDialog -derived class.

    I'm now using Qt 3.3.5 on Windows, developping under .NET03.
    Has anybody an idea?

  2. #2
    Join Date
    Jan 2006
    Location
    travelling
    Posts
    1,116
    Thanks
    8
    Thanked 127 Times in 121 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QDialog::exec() cereates no modal dialog

    Confusing !!! "exec()" should make your dialogs modal by default! Moreover you use "setModal(true)" and it doesn't make them modals

    It may be a bug in your version, or you may have forgotten to use that function with all dialogs that need it...

    If you doesn't forget anything I see only two ways to fix it :
    - recompiling you Qt 3 version
    - porting to Qt 4 (I've never heard of such a bug under Qt 4 and all the dialogs I call through "exec()" are modals!!!)
    Last edited by fullmetalcoder; 31st January 2006 at 14:33.
    Current Qt projects : QCodeEdit, RotiDeCode

  3. #3
    Join Date
    Jan 2006
    Location
    Ukraine,Lviv
    Posts
    454
    Thanks
    9
    Thanked 27 Times in 27 Posts
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Default Re: QDialog::exec() cereates no modal dialog

    Quote Originally Posted by fullmetalcoder
    If you doesn't forget anything I see only two ways to fix it :
    - recompiling you Qt 3 version
    - porting to Qt 4 (I've never heard of such a bug under Qt 4 and all the dialogs I call through "exec()" are modals!!!)
    no i dont think that.....i use qt3.3.5 and its work good with modal dialogs!
    I think sboesch hide for us some details...for example what it is?
    Qt Code:
    1. connect( m_pQDlgConfig, SIGNAL(signalUpdateTDMainWindow()), this, SLOT(SlotUpdateXSDTreeView()) );
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    Jan 2006
    Posts
    3
    Qt products
    Qt3
    Platforms
    MacOS X Windows

    Default Re: QDialog::exec() cereates no modal dialog

    Well,

    connect( m_pQDlgConfig, SIGNAL(signalUpdateTDMainWindow()), this, SLOT(SlotUpdateXSDTreeView()) );

    is a connection to the parent widget of the Dialog, which is needed to update a QListView when some data is being changed in the dialog.
    I alos thought about that being a problem and tried it without that connection - didn't work either.

    I'm not able to post all of the dialogs code - it has some 10,000 lines of code...

    I just wonder, if anybody has the same problem before, because I don't have an idea, what could be the problem.

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QDialog::exec() cereates no modal dialog

    Quote Originally Posted by sboesch
    m_pQDlgConfig = new SGenConfigDialog( this, "1" );
    Where does "this" point?

    Did you reimplement the exec() method in SGenConfigDialog?

  6. #6
    Join Date
    Jan 2006
    Posts
    3
    Qt products
    Qt3
    Platforms
    MacOS X Windows

    Default Re: QDialog::exec() cereates no modal dialog

    this points to a QMainWindow derived class.

    exec() is not reimplemented in SGenCondifDialog.

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QDialog::exec() cereates no modal dialog

    Could you provide a minimal example which reproduces the problem?

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QDialog::exec() cereates no modal dialog

    Quote Originally Posted by sboesch
    exec() is not reimplemented in SGenCondifDialog.
    What happens in the SGenCondifDialog constructor? How do you initialize its base class?

  9. #9
    Join Date
    Jan 2006
    Location
    Catalonia
    Posts
    266
    Thanks
    44
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QDialog::exec() cereates no modal dialog

    sboesch, I had a similar problem and the cause was that I called to show inside the dialog and it seems that blocked the modality or something.

Similar Threads

  1. Replies: 3
    Last Post: 1st February 2009, 15:49
  2. Modal dialog not behaving
    By tpf80 in forum Qt Programming
    Replies: 7
    Last Post: 16th September 2008, 22:03
  3. Special Modal Dialog
    By adonel in forum Qt Programming
    Replies: 2
    Last Post: 13th May 2008, 08:12
  4. System modal dialog!!
    By boss_bhat in forum Qt Programming
    Replies: 2
    Last Post: 23rd June 2006, 07:01
  5. dialog box
    By Bahar in forum Qt Programming
    Replies: 3
    Last Post: 31st January 2006, 14:52

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.