I use the following code, the first part, creating the QToolButton, is from Designer/moc, the rest I added.
// Moc part
QToolButton * f_tool_button = new QToolButton(bottom_grid);
f_tool_button->setObjectName(QStringLiteral("f_tool_button"));
f_tool_button->setText(QApplication::translate("MainWindow",
"Tool Button...", 0));
// What I added
f_action = new QAction(this);
f_action->setObjectName(QStringLiteral("f_action"));
f_action->setText(QApplication::translate("MainWindow",
"&Click...", 0));
f_menu.reset(new QMenu("Tool Button Menu ...", this));
f_menu->addAction(f_action);
f_tool_button->setDefaultAction(f_menu->menuAction());
If I don't call setDefaultAction()
, the title appears as expected.
When I add the default action, the label seems to be replaced by the f_menu
title, "Tool Button Menu ..." (I put a somewhat different label on purpose). But somehow the "..." gets removed from the name.
Any idea about this problem? Is that a special Qt feature?