PDA

View Full Version : QDialog with Close, Maximize and Context Help Buttons



mclark
15th December 2008, 21:21
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?:confused:

Is Windows conspiring against me yet again?

kwisp
17th December 2008, 10:47
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?:confused:

Is Windows conspiring against me yet again?

Can you represent your code here?

mclark
17th December 2008, 15:38
Can you represent your code here?

I used the following code (from the Windows Flags example in Qt Assistant):


Qt::WindowFlags flags = 0;
flags |= Qt::WindowMaximizeButtonHint;
flags |= Qt::WindowContextHelpButtonHint;
setWindowFlags( flags );
I tried passing the flag parameter into my dialog and using it as a parameter to QDialog.

MyDialog dlg( this, flags );

// The constructor looks like:
MyDialog::MyDialog( QWidget *parent, Qt::WindowFlags flags ) : QDialog( parent, flags )
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.

netmat
19th April 2010, 13:32
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

mclark
19th April 2010, 19:12
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

chshlin
8th November 2010, 03:45
Hi everyone, I also had this problem.
I found a easy solution here, sharing with you all.


int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Dialog w;
w.setWindowFlags(Qt::Window); // add this.
w.show();

return a.exec();
}

Best,

weixianlee
10th March 2017, 12:42
This helped, great thanks!

amelvill
1st May 2020, 16:53
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,