Results 1 to 9 of 9

Thread: How to hide Close Button "X" on Widget ?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2010
    Posts
    98
    Thanks
    19
    Thanked 8 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to hide Close Button "X" on Widget ?

    Ok,I find the flag.
    See the screenshot below:

    use Qt::CustomizeWindowHint,you will get no X button,but also no title....
    It's not the goodbye that hurts,but the flashback that follow.

  2. #2
    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 hide Close Button "X" on Widget ?

    Try http://www.qtcentre.org/threads/2454...112#post142112

    or alternatively, you could draw the title bar yourself.

  3. #3
    Join Date
    Jan 2010
    Posts
    1
    Thanked 3 Times in 1 Post
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to hide Close Button "X" on Widget ?

    I did it a few minutes ago for my application. In main.cpp, write:

    widget.setWindowFlags ( Qt::CustomizeWindowHint | Qt::WindowTitleHint);
    widget.show();
    Now you do not have close button, neither a menu close and ALT-F4 won't work.
    Hope this can be helpful.

    I'm using Qt4 under Linux

  4. The following 3 users say thank you to arnaizf for this useful post:

    francomartins (20th June 2012), maratk1n (14th April 2017), ShaChris23 (28th July 2010)

  5. #4
    Join Date
    Jan 2020
    Posts
    3
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android

    Default Re: How to hide Close Button "X" on Widget ?

    Quote Originally Posted by arnaizf View Post
    I did it a few minutes ago for my application. In main.cpp, write:



    Now you do not have close button, neither a menu close and ALT-F4 won't work.
    Hope this can be helpful.

    I'm using Qt4 under Linux
    I believe another way around would be hijacking close event, add this ti header file:
    Qt Code:
    1. private:
    2. void closeEvent(QCloseEvent *event) override;
    To copy to clipboard, switch view to plain text mode 

    and this to cpp file:
    Qt Code:
    1. void MainWindow::closeEvent(QCloseEvent *event)
    2. {
    3. cout << "Here in close" << endl;
    4. event->ignore();
    5. }
    To copy to clipboard, switch view to plain text mode 

    More info? https://doc.qt.io/qt-5/qwidget.html#closeEvent

Similar Threads

  1. Close Button on Modal Widget?
    By vishal.chauhan in forum Qt Programming
    Replies: 5
    Last Post: 18th February 2008, 11:38
  2. Replies: 3
    Last Post: 17th October 2007, 12:52

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.