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?:confused:
Is Windows conspiring against me yet again?
Re: QDialog with Close, Maximize and Context Help Buttons
Quote:
Originally Posted by
mclark
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?
Re: QDialog with Close, Maximize and Context Help Buttons
Quote:
Originally Posted by
kwisp
Can you represent your code here?
I used the following code (from the Windows Flags example in Qt Assistant):
Code:
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.
Code:
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.
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
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
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.
Code:
int main(int argc, char *argv[])
{
Dialog w;
w.setWindowFlags(Qt::Window); // add this.
w.show();
return a.exec();
}
Best,
Re: QDialog with Close, Maximize and Context Help Buttons
This helped, great thanks!
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:
Quote:
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:
Quote:
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,