Results 1 to 13 of 13

Thread: Diasble close button on a QDialog

  1. #1
    Join Date
    Jul 2007
    Posts
    57
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Diasble close button on a QDialog

    I hav created a Dialog ...I want to disable the close button on the dialog...

  2. #2
    Join Date
    Jan 2006
    Location
    Paris, France
    Posts
    227
    Thanks
    3
    Thanked 21 Times in 21 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Diasble close button on a QDialog

    Hello,

    You have to use setWindowFlags() method, and I think you'll have to omit this particular flag :

    Qt::WindowSystemMenuHint

  3. #3
    Join Date
    Jul 2007
    Posts
    57
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Diasble close button on a QDialog

    I have used designer to create the dialog. i hav used setContextMenuPolicy(Qt::NoContextMenu) to disable the maximize,minimize and close buttons.The ui file works fine for Windows OS but on Linux i am getting the close button on the dialog..Is there any option in the designer to remove the close button

  4. #4
    Join Date
    May 2006
    Location
    Bangalore,India
    Posts
    235
    Thanks
    7
    Thanked 25 Times in 24 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: Diasble close button on a QDialog

    use m_pCloseBtn->setEnabled(false);

  5. #5
    Join Date
    Jul 2007
    Posts
    57
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Diasble close button on a QDialog

    Its not the qPushButton the clse,maximize,minimize button the Dialog

  6. #6
    Join Date
    May 2006
    Location
    Bangalore,India
    Posts
    235
    Thanks
    7
    Thanked 25 Times in 24 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: Diasble close button on a QDialog

    you write following code, this will not disable but don't close your application.
    Qt Code:
    1. void MyWindow::closeEvent(QCloseEvent *event)
    2. {
    3. event->ignore();
    4. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by jacek; 16th July 2007 at 12:58.

  7. #7
    Join Date
    Jul 2007
    Posts
    57
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: To make close button on a QDialog invisble

    I have used designer to create the dialog. i hav used setContextMenuPolicy(Qt::NoContextMenu) to make the maximize,minimize and close buttons invisble.The ui file works fine for Windows OS but on Linux the close button on the dialog is visible ..Is there any option in the designer to remove the close button...Sorry for using the term disable its actually visiblity.....

  8. #8
    Join Date
    May 2006
    Location
    Bangalore,India
    Posts
    235
    Thanks
    7
    Thanked 25 Times in 24 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: Diasble close button on a QDialog

    this following code working for me on window.this code removing "X"button from title. I dont know it work on unix or not.
    Qt Code:
    1. setWindowFlags(Qt::FramelessWindowHint);
    2. setWindowFlags(Qt::WindowTitleHint);
    3. setWindowTitle(tr("Virtual Development Board"));
    To copy to clipboard, switch view to plain text mode 
    Last edited by jacek; 16th July 2007 at 12:58. Reason: changed [html] to [code]

  9. #9
    Join Date
    Jul 2007
    Posts
    57
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Diasble close button on a QDialog

    U r code works fine. But i do not get the title bar.Is there any way to hav the title bar with close button only..The maximize and minimize buttons on the MainWindow should be invisible....

  10. #10
    Join Date
    May 2006
    Location
    Bangalore,India
    Posts
    235
    Thanks
    7
    Thanked 25 Times in 24 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: Diasble close button on a QDialog

    see the example code Window Flags Example: from
    http://doc.trolltech.com/4.3/widgets-windowflags.html
    this example code working fine on windows. you test this on linux, in this example depend on different check box it showing minimize , maximize and close button, and none of these also.
    see void ControllerWindow::updatePreview() in example.

  11. #11
    Join Date
    Jul 2007
    Posts
    57
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Diasble close button on a QDialog

    I tested the code given in the website..It has solved my problem.I hav another one.I need a Dialog that has no close button on the dialog but has a titlebar...I tried using FramelessWindowHint but titlebar is not visible...Suggest some approach where i can hav a titlebar with no close button.

  12. #12
    Join Date
    May 2006
    Location
    Bangalore,India
    Posts
    235
    Thanks
    7
    Thanked 25 Times in 24 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: Diasble close button on a QDialog

    after FramelessWindowHint ,use WindowTitleHint then only titlebar will be visible
    Qt Code:
    1. setWindowFlags(Qt::FramelessWindowHint);
    2. setWindowFlags(Qt::WindowTitleHint);
    To copy to clipboard, switch view to plain text mode 

  13. The following user says thank you to rajesh for this useful post:

    ashishsaryar (10th October 2007)

  14. #13
    Join Date
    Jul 2007
    Posts
    57
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Diasble close button on a QDialog

    I tried with the code given by you.It gives a frameless window with no titlebar and the I tried with option setWindowFlags(Qt::Tool|Qt::FramelessWindowHint|Qt ::WindowTitleHint).Still i am not able to get the title bar with no close,max,min button.

Similar Threads

  1. Replies: 1
    Last Post: 7th July 2007, 09:03
  2. showing close Button(x) in QDialog
    By vishal.chauhan in forum Newbie
    Replies: 6
    Last Post: 4th April 2007, 10:01
  3. Replies: 2
    Last Post: 5th February 2007, 17:42
  4. Replies: 3
    Last Post: 16th November 2006, 12:24
  5. How to "hide window when close button pressed"
    By iGoo in forum Qt Programming
    Replies: 4
    Last Post: 26th July 2006, 09:53

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.