Skip to content

Instantly share code, notes, and snippets.

@ihewitt
Last active February 24, 2016 21:17
Show Gist options
  • Save ihewitt/8a3e15e60e8c7f20cf22 to your computer and use it in GitHub Desktop.
Save ihewitt/8a3e15e60e8c7f20cf22 to your computer and use it in GitHub Desktop.
accelerator menu text
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