bâtiment sur @ réponse de Wiz, j'ai fait la mienne un menu déroulant hors d'un bouton de la barre d'outils en utilisant des 11 fonctionnalités C++ (lambdas et automobiles, travaille avec VS2010 et gcc 4.6 avec Qt 5.1.1):
auto dialog = new QColorDialog();
dialog->setWindowFlags(Qt::Widget);
dialog->setOptions(QColorDialog::DontUseNativeDialog | QColorDialog::ShowAlphaChannel);
auto action = new QWidgetAction(0);
action->setDefaultWidget(dialog);
auto menu = new QMenu();
menu->addAction(action);
// The dialog-as-widget closes on Ok/cancel, but the menu that holds it
// doesn't. We connect the two here. Because the dialog hides itself,
// we need to reshow it when the menu is coming up again.
connect(menu, &QMenu::aboutToShow, [=] { dialog->show(); });
connect(dialog, &QColorDialog::rejected, [=] { menu->hide(); });
connect(dialog, &QColorDialog::colorSelected,
[=](const QColor& color)
{
menu->hide();
OnFillColorChanged(color); // Call the "slot" in this class
});
auto button = new QToolButton();
button->setIcon(QIcon(":/images/whatev.png"));
button->setText(tr("Fill"));
button->setStatusTip(tr("Choose fill color"));
button->setMenu(menu);
button->setPopupMode(QToolButton::InstantPopup);
button->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
toolbar->addWidget(button); // toolbar is defined elsewhere
C'est possible. Voir la solution @ Wiz ci-dessous. – metal