Stylesheets won't help you here QPushButton::menu-indicator is to style the little dropdown arrow you can draw on the pushbutton to show there is a menu ( I believe anyways )
Set an event filter on your menu, and re-position it on show
QMenu* menu
= new Menu
();
somePushButton->setMenu(menu);
menu->installEventFilter(this);
{
if (event
->type
() == QEvent::Show && obj
== somePushButton
->menu
()) {
QPoint pos
= calculateposition
somePushButton->menu()->move(pos);
return true;
}
return false;
}
QMenu* menu = new Menu();
somePushButton->setMenu(menu);
menu->installEventFilter(this);
bool myWidget::eventFilter(QObject * obj, QEvent *event)
{
if (event->type() == QEvent::Show && obj == somePushButton->menu())
{
QPoint pos = calculateposition
somePushButton->menu()->move(pos);
return true;
}
return false;
}
To copy to clipboard, switch view to plain text mode
If this is something you want to do in general on all of your QPushButtons you should subclass QPushButton and apply the menu event filter in the setMenu function, then use promotion in designer to always create your custom push buttons instead.
Bookmarks