Hello! QAction is meant to work together with QPushButtons, right? Somehow it doesn't work out for me. I defined a QAction and it works nicely on a QMenuBar, but when I try to add it to a QPushButton, nothing happens. I mean the button doesn't trigger the action. Here is my code.
recordAction->setToolTip(tr("Toggles recording."));
connect(recordAction, SIGNAL(triggered()), this, SLOT(record()));
menuBar->addAction(recordAction);
ui.recordButton->addAction(recordAction);
QAction* recordAction = new QAction(tr("&Record"), this);
recordAction->setToolTip(tr("Toggles recording."));
recordAction->setShortcut(QKeySequence(tr("Return")));
connect(recordAction, SIGNAL(triggered()), this, SLOT(record()));
QMenuBar* menuBar = new QMenuBar();
menuBar->addAction(recordAction);
ui.recordButton->addAction(recordAction);
To copy to clipboard, switch view to plain text mode
The button and the whole ui has been created with Qt Designer.
What am I doing wrong?
Bookmarks