Answer the question
In order to leave comments, you need to log in
Qt: how to disable a HUGE QPushButton menu under Windows?
Here is the code.
#include <QApplication>
#include <QMainWindow>
#include <QPushButton>
#include <QMenu>
#include <QMessageBox>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QMainWindow w;
auto pW = &w;
QPushButton* btShowMenu = new QPushButton("Some menu", pW);
QMenu* menu = new QMenu(pW);
auto lambdaMessage = [pW]() {
QMessageBox::information(pW, "Clicked!", "Clicked!");
};
for (int i = 0; i < 50; ++i) {
QAction* ac = menu->addAction("Menu item");
QObject::connect(ac, &QAction::triggered, lambdaMessage);
}
btShowMenu->setMenu(menu);
w.show();
return a.exec();
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question