Results 1 to 13 of 13

Thread: How do i close a buttonless dialog.

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2010
    Posts
    7
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How do i close a buttonless dialog.

    Updated mainwindow.cpp to show the form with:
    Qt Code:
    1. purge dialog(this);
    2. dialog.exec()
    To copy to clipboard, switch view to plain text mode 

    Updated purge.h to:
    Qt Code:
    1. protected:
    2. void changeEvent(QEvent *e);
    3. void showEvent(QShowEvent *);
    4. void closeEvent(QCloseEvent *e);
    To copy to clipboard, switch view to plain text mode 

    Updated purge.cpp to make a call to purgeCache function in the showEvent:
    Qt Code:
    1. void purge::showEvent(QShowEvent *)
    2. {
    3. qDebug() << "in the show event";
    4. purge::purgeCache();
    5. }
    To copy to clipboard, switch view to plain text mode 

    Updated purge.cpp to output when the closeEvent occurs:
    Qt Code:
    1. void purge::closeEvent(QCloseEvent *e)
    2. {
    3. qDebug() << " in the close event";
    4. }
    To copy to clipboard, switch view to plain text mode 

    I can clearly see the call to close the window, yet it does not close.
    Also, now that I am calling the purgeCache function from the showEvent, and the purgeCache function includes "close()" the form will not close whatsoever. Every time I click the close button on the window manager, it outputs "in the close event", so I show to be in the close handler, yet it doesn't happen, and I have to kill the app.

    Once again, I apprecaite your input

  2. #2
    Join Date
    Jan 2010
    Posts
    7
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How do i close a buttonless dialog.

    I had to cheat to make it work the way I wanted.

    I added a check in the changeEvent:
    Qt Code:
    1. if (strPurged == "True")
    2. close();
    To copy to clipboard, switch view to plain text mode 

    At the end of the purgeCache function I assign True to strPurged.

    I noticed that even though I enter the closeEvent and the window wouldn't close, that a call was made to the changeEvent since closing is a changeEvent.

    Although this is a bit hackish it works. If there is a better way please let me know.

  3. #3
    Join Date
    Jan 2006
    Location
    Shanghai, China
    Posts
    52
    Thanks
    3
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How do i close a buttonless dialog.

    After you override those virtual function, you should call the original version to make it do original things. e.g.
    Qt Code:
    1. void purge::closeEvent(QCloseEvent *e)
    2. {
    3. qDebug() << " in the close event";
    4. QDialog::closeEvent(e);
    5. }
    To copy to clipboard, switch view to plain text mode 
    1. Users don't have the manual, and if they did, they wouldn't read it.
    2. In fact, users can't read anything, and if they could, they wouldn't want to.

  4. #4
    Join Date
    Jan 2010
    Posts
    7
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How do i close a buttonless dialog.

    Will try thanks for the help.

Similar Threads

  1. Delete/Close Dialog correct?
    By kei in forum Qt Programming
    Replies: 8
    Last Post: 2nd July 2009, 13:51
  2. Close Dialog in showEvent
    By pospiech in forum Qt Programming
    Replies: 3
    Last Post: 11th April 2008, 15:32
  3. Block close dialog
    By Mrdata in forum Newbie
    Replies: 2
    Last Post: 12th March 2007, 15:39
  4. Replies: 2
    Last Post: 5th February 2007, 17:42
  5. Replies: 3
    Last Post: 23rd July 2006, 18:02

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.