PDA

View Full Version : Shortcut QKeySequence::HelpContents and Modal Dialog



lsbts1291
28th January 2014, 13:41
In a modal dialog i set the shortcut QKeySequence::HelpContents to the help button, but this shortcut is not working, the button is not clicked if I press the corresponding shortcut.



DialogWithHelpButton::DialogWithHelpButton(QWidget *parent) :
QDialog(parent), ui(new Ui::DialogWithHelpButton)
{
ui->setupUi(this);
QPushButton *helpButton = ui->buttonBox->button(QDialogButtonBox::Help);
helpButton->setShortcut(QKeySequence::HelpContents);
}


I did some tests, and it seems, that the shortcuts QKeySequence::HelpContents only work if set to an action in the menu of the main application windows. If I open the dialog as non modal, the application shortcut also work, but not if the dialog is open as modal.



MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent), ui(new Ui::MainWindow)
{
ui->setupUi(this);

QMenu *helpMenu = new QMenu("Help", this);
menuBar()->addMenu(helpMenu);
QAction *helpAction = helpMenu->addAction("Help index", this, SLOT(openHelp()));
helpAction->setShortcut(QKeySequence::HelpContents);
}


I tried also with an event filter in the dialog and in the application, but when i press under mac the Command-? or under windows F1 i see the event for the Command key but not for the ? key. I don't understand who is eating this key press.

Someone can explain me where the error is? Is these a way to connect QKeySequence::HelpContents to the help button in a dialog?

Thanks.