Results 1 to 3 of 3

Thread: Enable and Disable Close (X)

  1. #1
    Join Date
    Oct 2014
    Posts
    71
    Thanks
    13
    Qt products
    Qt5
    Platforms
    Windows

    Default Enable and Disable Close (X)

    Hello,

    How can I enable and disable the Close (X) button on Qt window

  2. #2
    Join Date
    Apr 2013
    Location
    Prague
    Posts
    256
    Thanks
    3
    Thanked 65 Times in 59 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Enable and Disable Close (X)

    By reimplementing closeEvent() method. You can ignore() (disable the 'X') or accept() (enable the 'X') the event. Note that this affects all kinds of closing the window, not only 'X'. Also, see delete on close flag and decide, whether you want only to hide the window or whether the window should be destroyed. See the QWidget::closeEvent description in the manual.

  3. #3
    Join Date
    Dec 2009
    Location
    New Orleans, Louisiana
    Posts
    791
    Thanks
    13
    Thanked 153 Times in 150 Posts
    Qt products
    Qt5
    Platforms
    MacOS X

    Default Re: Enable and Disable Close (X)

    Quote Originally Posted by anh5kor View Post
    How can I enable and disable the Close (X) button on Qt window
    Look at QWindow::setFlags(). I believe there are some platform restrictions in play, but you can try removing the close button by using a custom window hint (Qt::CustomizeWindowHint) and removing the close button by ensuring Qt::WindowCloseButtonHint is removed from the window flags.

    Read the full docs for QWindow::setFlags() to see the platform dependencies, etc.

    Hope that helps.

Similar Threads

  1. pyQT how do I enable or disable a pushbutton from the main code?
    By Michael Druckenmiller Sr in forum Newbie
    Replies: 1
    Last Post: 12th January 2012, 18:44
  2. Enable/Disable Zoom with a checkable action
    By yannwilfried in forum Qwt
    Replies: 2
    Last Post: 2nd December 2009, 15:30
  3. disable enable network connections?
    By remy06 in forum Qt Programming
    Replies: 2
    Last Post: 8th May 2009, 17:52
  4. Replies: 1
    Last Post: 18th December 2008, 10:25
  5. disable/enable shortcut
    By harakiri in forum Qt Programming
    Replies: 2
    Last Post: 6th May 2007, 10:58

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.