Results 1 to 4 of 4

Thread: How to hide close button in QDialog?

  1. #1
    Join Date
    Aug 2009
    Location
    Brisbane, Australia
    Posts
    75
    Thanks
    18
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default How to hide close button in QDialog?

    Hi,

    Just wondering how to hide the close button on a QDialog?

    Thanks
    Brendan

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to hide close button in QDialog?

    By modifying flags set on the widget. Just be aware this will only hide the button, it won't prevent your dialog from being closable.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. The following user says thank you to wysota for this useful post:

    grantbj74 (27th September 2011)

  4. #3
    Join Date
    Aug 2009
    Location
    Brisbane, Australia
    Posts
    75
    Thanks
    18
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to hide close button in QDialog?

    Thanks.

    I looked at the Window Flags Example in Qt Assistant. Unfortunately Qt::SubWindow wasn't included and this was the only flag that hid the close button.

    This is what worked in the end, I put it in the dialog constructor.

    Qt Code:
    1. this->setWindowFlags(Qt::SubWindow);
    To copy to clipboard, switch view to plain text mode 

  5. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to hide close button in QDialog?

    No, that's not a good approach. You need to use Qt::CustomizeWindowHint and remove Qt::WindowCloseButtonHint from the hints passed to the window.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Disable Close button (X) of a QDialog
    By BrainB0ne in forum Qt Programming
    Replies: 29
    Last Post: 8th December 2009, 17:01
  2. QDialog not showing close button on Mac
    By manojmka in forum Qt Programming
    Replies: 2
    Last Post: 17th September 2008, 12:56
  3. Diasble close button on a QDialog
    By Krish_ng in forum Qt Programming
    Replies: 12
    Last Post: 17th July 2007, 04:23
  4. Replies: 1
    Last Post: 7th July 2007, 09:03
  5. showing close Button(x) in QDialog
    By vishal.chauhan in forum Newbie
    Replies: 6
    Last Post: 4th April 2007, 10:01

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.