Results 1 to 5 of 5

Thread: How to Disabel close button on top corner of widget

  1. #1
    Join Date
    Apr 2009
    Posts
    41
    Qt products
    Qt4
    Platforms
    Windows

    Question How to Disabel close button on top corner of widget

    Hi,
    i want to disable close button on top corner of the widget/ show only minimize and maximize buttons. If it is not possible which signal trigger when we close window? Because i have to load data into database when we close widget.

    Can any one help me please? Thanks in advance.

  2. #2
    Join Date
    Dec 2007
    Posts
    628
    Thanks
    3
    Thanked 89 Times in 87 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to Disabel close button on top corner of widget

    Quote Originally Posted by jsmith View Post
    i want to disable close button on top corner of the widget/ show only minimize and maximize buttons.
    I am not sure for enable/disable but you can hide those buttons by playing with WindowsFlags. See this example.

    Quote Originally Posted by jsmith View Post
    which signal trigger when we close window
    For a Dialog
    void accepted ()
    void rejected ()

    For Widget
    QWidget::closeEvent()

  3. #3
    Join Date
    Mar 2010
    Posts
    92
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Default Re: How to Disabel close button on top corner of widget

    Quote Originally Posted by jsmith View Post
    Hi,
    i want to disable close button on top corner of the widget/ show only minimize and maximize buttons. If it is not possible which signal trigger when we close window? Because i have to load data into database when we close widget.

    Can any one help me please? Thanks in advance.
    i want disalbe close button and minimize button and maximize button,how ?

  4. #4
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to Disabel close button on top corner of widget

    Have you tried using GetSystemMenu and then using EnableMenuItem on the "Close" item ? Theoretically, if you disable the Close menu item, it will disable the close button too.

  5. #5
    Join Date
    Jun 2010
    Posts
    5
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to Disabel close button on top corner of widget

    <code>

    this->setWindowFlags((
    (windowFlags() | Qt::CustomizeWindowHint)
    & ~Qt::WindowCloseButtonHint
    ));
    </code>

Similar Threads

  1. How to hide Close Button "X" on Widget ?
    By merry in forum Qt Programming
    Replies: 8
    Last Post: 25th January 2020, 08:03
  2. Playbutton functionality
    By uchennaanyanwu in forum Qt Programming
    Replies: 5
    Last Post: 31st July 2008, 22:29
  3. How to Open & Close a Widget ?!!
    By Fatla in forum Qt Programming
    Replies: 6
    Last Post: 13th June 2008, 20:39
  4. Close Button on Modal Widget?
    By vishal.chauhan in forum Qt Programming
    Replies: 5
    Last Post: 18th February 2008, 11:38
  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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.