Results 1 to 20 of 30

Thread: Disable Close button (X) of a QDialog

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #13
    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: Disable Close button (X) of a QDialog

    That's MFC, not WinAPI...
    Qt Code:
    1. #include <QtGui>
    2. #ifdef Q_WS_WIN
    3. #include <qt_windows.h>
    4. #endif // Q_WS_WIN
    5.  
    6. int main(int argc, char *argv[])
    7. {
    8. QApplication app(argc, argv);
    9. QWidget window;
    10.  
    11. #ifdef Q_WS_WIN
    12. HMENU menu = ::GetSystemMenu(window.winId(), FALSE);
    13. ::DeleteMenu(menu, SC_CLOSE, MF_BYCOMMAND);
    14. ::EnableMenuItem(menu, SC_CLOSE, MF_BYCOMMAND | MF_GRAYED);
    15. // or (removes the item in of system menu)
    16. // ::DeleteMenu(menu, SC_CLOSE, MF_BYCOMMAND);
    17. #endif // Q_WS_WIN
    18.  
    19. window.show();
    20. return app.exec();
    21. }
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

  2. The following user says thank you to jpn for this useful post:

    BrainB0ne (10th October 2007)

Similar Threads

  1. Diasble close button on a QDialog
    By Krish_ng in forum Qt Programming
    Replies: 12
    Last Post: 17th July 2007, 04:23
  2. Replies: 1
    Last Post: 7th July 2007, 09:03
  3. Disable Checkable Button Question
    By jbpvr in forum Qt Programming
    Replies: 9
    Last Post: 20th March 2007, 17:57
  4. Replies: 2
    Last Post: 5th February 2007, 17:42
  5. Replies: 3
    Last Post: 16th November 2006, 12:24

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.