QToolButton menu-button position
Unsolved
General and Desktop
-
Hi, I would expect this menu-button to appear below the QToolButton, however it always appears to the right. How do I specify the location of the menu-button relative to the QToolButton with stylesheets?
#include "mainwindow.h" #include "qtoolbutton.h" #include "qmenu.h" #include "qgridlayout.h" #include <QApplication> int main(int argc, char *argv[]) { QApplication a(argc, argv); MainWindow w; QWidget wig; QGridLayout* layout = new QGridLayout(); QString style = "QToolButton[popupMode=\"1\"]{" " background: pink;" " }" "QToolButton::menu-button {" " subcontrol-position: bottom;" " subcontrol-origin: margin;" " background: red;" "}"; a.setStyleSheet(style); QMenu *menu = new QMenu(); QAction *testAction = new QAction("test menu item"); menu->addAction(testAction); QToolButton* toolBtn = new QToolButton(); toolBtn->setText("Tool Button"); toolBtn->setMenu(menu); toolBtn->setPopupMode(QToolButton::MenuButtonPopup); layout->addWidget(toolBtn); wig.setLayout(layout); w.setCentralWidget(&wig); w.show(); return a.exec(); }