how to change the position of the menu popped by the qpushbutton?
-
wrote on 20 Feb 2025, 03:42 last edited by
I just added the menu and action ,so that if someone clicked the button then the menu would popped on the button.but I found that the menu was very closed to the qpushbutton.so how to change it by using the qss .the way I used was invalid.
QPushButton QMenu{
top:-12px;
border:none;
border-radius:6px;}
QPushButton QAction{
font:10px;
border:none;
} -
wrote on 20 Feb 2025, 05:46 last edited by
Use menu.popup(button.mapToGlobal(QPoint(x, y))) to set a custom position where x and y adjust the menu's placement relative to the button.
-
Use menu.popup(button.mapToGlobal(QPoint(x, y))) to set a custom position where x and y adjust the menu's placement relative to the button.
wrote on 20 Feb 2025, 06:32 last edited by@Signal_Slayer
I knew that.but i just wondered if there's a method that could change the position by using the qss style. -
qss is for styling. Positioning a widget has nothing to do with styling.
-
wrote on 20 Feb 2025, 07:14 last edited by
by the way.how to change the outlook of the qcombobox by using the qss.the arrow and the right part is so ugly.it is not the operating system default style. -
by the way.how to change the outlook of the qcombobox by using the qss.the arrow and the right part is so ugly.it is not the operating system default style.@nicker-player said in how to change the position of the menu popped by the qpushbutton?:
it is not the operating system default style
What is your OS?
Did you do any styling already in your app?
There is documentation which should answer your question: https://doc.qt.io/qt-6/stylesheet-examples.html#customizing-qcombobox
5/6