Results 1 to 8 of 8

Thread: QDialog with Close, Maximize and Context Help Buttons

  1. #1
    Join Date
    Aug 2006
    Location
    Madison, WI USA
    Posts
    153
    Thanks
    35
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Question QDialog with Close, Maximize and Context Help Buttons

    I'm using Qt 4.4.2 and MSWindows XP SP3.

    I am looking to create a QDialog with a close button, maximize button and context help button in the upper right corner. I've run the Window Flags Example but this will only give me close, maximize and disabled minimize buttons OR the close and context help buttons.

    Am I asking for the impossible?

    Is Windows conspiring against me yet again?

  2. #2
    Join Date
    Dec 2008
    Location
    TaganrogNativelandChehov,Russia
    Posts
    64
    Thanks
    1
    Thanked 8 Times in 7 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QDialog with Close, Maximize and Context Help Buttons

    Quote Originally Posted by mclark View Post
    I'm using Qt 4.4.2 and MSWindows XP SP3.

    I am looking to create a QDialog with a close button, maximize button and context help button in the upper right corner. I've run the Window Flags Example but this will only give me close, maximize and disabled minimize buttons OR the close and context help buttons.

    Am I asking for the impossible?

    Is Windows conspiring against me yet again?
    Can you represent your code here?

  3. #3
    Join Date
    Aug 2006
    Location
    Madison, WI USA
    Posts
    153
    Thanks
    35
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QDialog with Close, Maximize and Context Help Buttons

    Quote Originally Posted by kwisp View Post
    Can you represent your code here?
    I used the following code (from the Windows Flags example in Qt Assistant):

    Qt Code:
    1. Qt::WindowFlags flags = 0;
    2. flags |= Qt::WindowMaximizeButtonHint;
    3. flags |= Qt::WindowContextHelpButtonHint;
    4. setWindowFlags( flags );
    To copy to clipboard, switch view to plain text mode 
    I tried passing the flag parameter into my dialog and using it as a parameter to QDialog.
    Qt Code:
    1. MyDialog dlg( this, flags );
    2.  
    3. // The constructor looks like:
    4. MyDialog::MyDialog( QWidget *parent, Qt::WindowFlags flags ) : QDialog( parent, flags )
    To copy to clipboard, switch view to plain text mode 
    I also tried the code inside the constructor of the dialog.

    On the Windows XP platform, it appears that anytime you use the WindowMaximizeButtonHint the context help button is not displayed.

  4. #4
    Join Date
    Feb 2010
    Posts
    20
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Default Re: QDialog with Close, Maximize and Context Help Buttons

    hi Mclark,

    I have managed to have the help button on the left of the close button but need a way to connect it to a slot.
    Would pls, tell me signal it generates and what would be the name of the help (?) button.

    Thanks in advance,
    Netmat

  5. #5
    Join Date
    Aug 2006
    Location
    Madison, WI USA
    Posts
    153
    Thanks
    35
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QDialog with Close, Maximize and Context Help Buttons

    The help button is not conncted via signal/slot as far as I know.

    The way it works is you click it and get the '?' cursor. You move that cursor over some UI widget and click. If you have set the 'whatsThis' string for that widget, that string will appear similarly to a tooltip.

    http://qt.nokia.com/doc/4.6/qwidget.html#whatsThis-prop

  6. #6
    Join Date
    Nov 2010
    Posts
    1
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: QDialog with Close, Maximize and Context Help Buttons

    Hi everyone, I also had this problem.
    I found a easy solution here, sharing with you all.

    Qt Code:
    1. int main(int argc, char *argv[])
    2. {
    3. QApplication a(argc, argv);
    4. Dialog w;
    5. w.setWindowFlags(Qt::Window); // add this.
    6. w.show();
    7.  
    8. return a.exec();
    9. }
    To copy to clipboard, switch view to plain text mode 

    Best,

  7. #7
    Join Date
    Mar 2017
    Posts
    2
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: QDialog with Close, Maximize and Context Help Buttons

    This helped, great thanks!

  8. #8
    Join Date
    May 2020
    Posts
    1
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QDialog with Close, Maximize and Context Help Buttons

    To add a bit more information to chshlin's post:

    Note that you can find the complete selection of WindowFlags here:
    https://doc.qt.io/qt-5/qt.html#WindowType-enum

    Qt:: Window has this description:
    Indicates that the widget is a window, usually with a window system frame and a title bar, irrespective of whether the widget has a parent or not. Note that it is not possible to unset this flag if the widget does not have a parent.
    Qt:: Dialog (which seems to be the default for Dialogs) has this description:
    Indicates that the widget is a window that should be decorated as a dialog (i.e., typically no maximize or minimize buttons in the title bar). This is the default type for QDialog. If you want to use it as a modal dialog, it should be launched from another window, or have a parent and used with the QWidget::windowModality property. If you make it modal, the dialog will prevent other top-level windows in the application from getting any input. We refer to a top-level window that has a parent as a secondary window.
    From my testing it appears that you can set Qt ::Window as the window flag without affecting whether the dialog is modal (as in, you can set this flag and still prevent input to the window that showed the dialog).

    Hope that helps,

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.