Results 1 to 7 of 7

Thread: Dialog closes on pressing Esc key?

  1. #1
    Join Date
    Dec 2006
    Posts
    211
    Thanks
    27
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Question Dialog closes on pressing Esc key?

    Hi All,

    I am using Qt 4.3.3 on my Mac.
    I have a dialog and when I press the Esc key the dialog get closed.
    So how should I avoid this? that is the dialog should not closed on pressing Esc key.

    Thanks.

  2. #2
    Join Date
    Jan 2008
    Posts
    72
    Thanks
    3
    Thanked 4 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Default Re: Dialog closes on pressing Esc key?

    what did you set Qt::WindowFlags for that dialog ,check it ....................

  3. #3
    Join Date
    Dec 2006
    Posts
    211
    Thanks
    27
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Dialog closes on pressing Esc key?

    setWindowFlags(Qt:ialog | Qt::WindowSystemMenuHint | Qt::WindowMinimizeButtonHint);

  4. #4
    Join Date
    Jan 2008
    Posts
    72
    Thanks
    3
    Thanked 4 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Default Re: Dialog closes on pressing Esc key?

    Simply set its window Flag Qt::Window, I hope it help you,
    you can also prevent your escape key event by explicitly change its event using keyPressEevnt(QKeyEvent *event).........

  5. #5
    Join Date
    Dec 2006
    Posts
    211
    Thanks
    27
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Dialog closes on pressing Esc key?

    Thanks for the reply.

    Actually it does not make any difference when I use Qt::Windows flag but I will try out second method of changing the keyPressEvent.

  6. #6
    Join Date
    Dec 2006
    Posts
    211
    Thanks
    27
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Dialog closes on pressing Esc key?

    Yes the key event method does work.
    Thanks.

  7. #7
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Dialog closes on pressing Esc key?

    J-P Nurmi

Similar Threads

  1. Resizing the dialog boxes
    By anju123 in forum Qt Programming
    Replies: 4
    Last Post: 14th September 2007, 10:41
  2. QGraphicsView: Dialog Position Doubt
    By arjunasd in forum Qt Programming
    Replies: 1
    Last Post: 6th August 2007, 17:48
  3. Dialog closes immediately
    By bruccutler in forum Qt Programming
    Replies: 5
    Last Post: 21st February 2007, 23:18
  4. dialog box
    By Bahar in forum Qt Programming
    Replies: 3
    Last Post: 31st January 2006, 14:52
  5. QLineedit::returnPressed() closes dialog?
    By geranol in forum Newbie
    Replies: 2
    Last Post: 6th January 2006, 10:18

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.