Results 1 to 8 of 8

Thread: How can I avoid a QDialog close?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2009
    Posts
    132
    Thanks
    67
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How can I avoid a QDialog close?

    It seems if I rewrite
    void CSequencesDialog::closeEvent(QCloseEvent *event) {
    works, but if I try to write
    event->accept();
    Or
    event->ignore();

    [/code]
    1>.\CSequencesDialog.cpp(475) : error C2027: use of undefined type 'QCloseEvent'
    1> c:\qt\2009.01\qt\include\qtgui\../../src/gui/kernel/qwidget.h(83) : see declaration of 'QCloseEvent'
    1>.\CSequencesDialog.cpp(475) : error C2227: left of '->accept' must point to class/struct/union/generic type
    1>.\CSequencesDialog.cpp(477) : error C2027: use of undefined type 'QCloseEvent'
    1> c:\qt\2009.01\qt\include\qtgui\../../src/gui/kernel/qwidget.h(83) : see declaration of 'QCloseEvent'
    1>.\CSequencesDialog.cpp(477) : error C2227: left of '->ignore' must point to class/struct/union/generic type
    1>Build log was saved at "file://c:\Documents and Settings\Ricardo\Escritorio\iPhone\Kokochiko\Edito r\Editor\Debug\BuildLog.htm"
    1>Editor - 4 error(s), 0 warning(s)
    [code]

    Any idea?

  2. #2
    Join Date
    Apr 2009
    Posts
    132
    Thanks
    67
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How can I avoid a QDialog close?

    Bad news. I read this on Qt docs:

    "If the user presses the Esc key in a dialog, QDialog::reject() will be called. This will cause the window to close: The close event cannot be ignored."

    So, is that impossible?

    Thanks.

  3. #3
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How can I avoid a QDialog close?

    May be you can try overriding QWidget::keyPressEvent or QWidget::keyReleaseEventand compare something like -
    Qt Code:
    1. if(event->key() == Qy::Key_Esc)
    2. event->ignore(); // or do nothing, dont call base call function for this case
    To copy to clipboard, switch view to plain text mode 
    Last edited by aamer4yu; 11th May 2009 at 05:33.

  4. The following user says thank you to aamer4yu for this useful post:

    ricardo (11th May 2009)

  5. #4
    Join Date
    Apr 2009
    Posts
    132
    Thanks
    67
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How can I avoid a QDialog close?

    I have a similar problem if I use keyPressEvent. It seems parameter is not recognized.

    Qt Code:
    1. >CSequencesDialog.cpp
    2. 1>.\CSequencesDialog.cpp(486) : error C2027: use of undefined type 'QKeyEvent'
    3. 1> c:\qt\2009.01\qt\include\qtgui\../../src/gui/kernel/qwidget.h(78) : see declaration of 'QKeyEvent'
    4. 1>.\CSequencesDialog.cpp(486) : error C2227: left of '->key' must point to class/struct/union/generic type
    5. 1>.\CSequencesDialog.cpp(486) : error C2653: 'Qy' : is not a class or namespace name
    6. 1>.\CSequencesDialog.cpp(486) : error C2065: 'Key_Esc' : undeclared identifier
    7. 1>.\CSequencesDialog.cpp(486) : error C2027: use of undefined type 'QKeyEvent'
    8. 1> c:\qt\2009.01\qt\include\qtgui\../../src/gui/kernel/qwidget.h(78) : see declaration of 'QKeyEvent'
    9. 1>.\CSequencesDialog.cpp(486) : error C2227: left of '->ignore' must point to class/struct/union/generic type
    10. 1>CEditor.cpp
    11. 1>Generating Code...
    To copy to clipboard, switch view to plain text mode 

  6. #5
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How can I avoid a QDialog close?

    you forgot to include
    Qt Code:
    1. #include <QKeyEvent>
    To copy to clipboard, switch view to plain text mode 
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  7. The following user says thank you to spirit for this useful post:

    ricardo (11th May 2009)

  8. #6
    Join Date
    Apr 2009
    Posts
    132
    Thanks
    67
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How can I avoid a QDialog close?

    Thanks a lot, it worked.

Similar Threads

  1. QDialog with Close, Maximize and Context Help Buttons
    By mclark in forum Qt Programming
    Replies: 7
    Last Post: 1st May 2020, 16:53
  2. Disable Close button (X) of a QDialog
    By BrainB0ne in forum Qt Programming
    Replies: 29
    Last Post: 8th December 2009, 17:01
  3. QDialog not showing close button on Mac
    By manojmka in forum Qt Programming
    Replies: 2
    Last Post: 17th September 2008, 12:56
  4. Why when I close QDialog my main application gets killed?
    By alex chpenst in forum Qt Programming
    Replies: 2
    Last Post: 10th July 2008, 22:57
  5. Replies: 1
    Last Post: 7th July 2007, 09:03

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
  •  
Qt is a trademark of The Qt Company.