Last active
February 24, 2016 21:17
-
-
Save ihewitt/8a3e15e60e8c7f20cf22 to your computer and use it in GitHub Desktop.
accelerator menu text
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MainWindow::MainWindow(QWidget *parent) : | |
QMainWindow(parent), | |
ui(new Ui::MainWindow) | |
{ | |
ui->setupUi(this); | |
QListWidget *lw = new QListWidget; | |
this->setCentralWidget(lw); | |
QMenuBar *menubar = new QMenuBar; | |
QMenu *menu = new QMenu("Main"); | |
QAction *menuaction = menu->addAction("Pedal Force vs Velocity"); | |
menubar->addMenu(menu); | |
connect(menu, SIGNAL(triggered(QAction*)), this, SLOT(selected(QAction*))); | |
lw->addItem(QString("menuaction->text(): %1").arg( menuaction->text())); // This prints "Pedal Force vs Velocity" | |
this->setMenuBar(menubar); | |
} | |
void MainWindow::selected(QAction *ac) | |
{ | |
QListWidget *lw = (QListWidget*)centralWidget(); | |
lw->addItem(QString("selected action->text(): %1").arg( ac->text()));// This prints "&Pedal Force vs Velocity" | |
lw->addItem(QString("selected action->tooltip(): %1").arg( ac->toolTip()));// This prints "Pedal Force vs Velocity" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment