In a modal dialog i set the shortcut http://doc.qt.io/qt-4.8/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);
}
DialogWithHelpButton::DialogWithHelpButton(QWidget *parent) :
QDialog(parent), ui(new Ui::DialogWithHelpButton)
{
ui->setupUi(this);
QPushButton *helpButton = ui->buttonBox->button(QDialogButtonBox::Help);
helpButton->setShortcut(QKeySequence::HelpContents);
}
To copy to clipboard, switch view to plain text mode
I did some tests, and it seems, that the shortcuts http://doc.qt.io/qt-4.8/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
) :{
ui->setupUi(this);
menuBar()->addMenu(helpMenu);
QAction *helpAction
= helpMenu
->addAction
("Help index",
this,
SLOT(openHelp
()));
}
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);
}
To copy to clipboard, switch view to plain text mode
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.
Bookmarks