-
-
Save tracernz/5b24ee0bd1e3f065ff3712cdf7708f3a to your computer and use it in GitHub Desktop.
QAction::ApplicationSpecificRole demo
This file contains 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
#include "mainwindow.h" | |
#include "ui_mainwindow.h" | |
#include <QAction> | |
#include <QMenuBar> | |
#include <iostream> | |
MainWindow::MainWindow(QWidget *parent) : | |
QMainWindow(parent), | |
ui(new Ui::MainWindow) | |
{ | |
ui->setupUi(this); | |
auto action = new QAction("Test"); | |
action->setMenuRole(QAction::ApplicationSpecificRole); | |
connect(action, &QAction::triggered, []{ std::cout << "lol" << std::endl; }); | |
auto file = menuBar()->addMenu("File"); | |
file->addAction(action); | |
} | |
MainWindow::~MainWindow() | |
{ | |
delete ui; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment