2

Can anyone please tell me how to hide the right arrow for the QMenu items. I tried using the stylesheet. But it didn't works.. Please Help.

MyStylesheet.qss

QMenu::right-arrow[hide="true"]
{
  image: url(Resources/MenuRight.png); //am using an unavailable image so that it will return empty.
}

and in code i have set the property as,

menuItem->setProperty("hide", true);

but in the stylesheet(shown below) if i remove the dynamic property, then it is working fine. the background color of the right arrow changes to red.

QMenu::right-arrow
{
   background-color: red;
}
New Moon
  • 787
  • 6
  • 21
  • 35
  • 1
    Right arrow is displayed when you have a submenu under the current entry. You should not hide it because it is part of plateform guidelines and usual user experience. If you have an arrow without submenu, you probably did something wrong. Can you provide a little code showing how you create your menu and how you append items ? – Antwane Dec 13 '13 at 10:12
  • Thanks for your reply Antoine Lorence. Actually i am trying to drag and drop the menu items. An Action cannot be dragged since it is inherited from an Object. So intead of using a QAction I made it as QMenu. By default, the QMenu comes with a right arrow key (either the sub menu is there or not). So I want to hide the right arrow for that particular actions. (which i have changed it as menu's). – New Moon Dec 14 '13 at 16:35
  • You should instead create a QMenu subclass to implements drag and drop directly inside it. Even if QAction cannot be dragged/dropped, you can manage this feature from the parent menu. See http://www.qtcentre.org/threads/23278-Draggable-QActions-in-Qt and many many other examples over the internet (https://www.google.fr/search?q=dragging+qmenu&ie=utf-8&oe=utf-8&rls=org.mozilla:fr:official&client=firefox-a&channel=fflb&gws_rd=cr&ei=n9esUvbnFqeQ0AX4oYCwCQ#channel=fflb&q=drag+and+drop+qaction+qmenu&rls=org.mozilla:fr:official) – Antwane Dec 14 '13 at 22:16

1 Answers1

1

You can use the menu-indicator property in the stylesheet of the item.

Here with a QPushButton:

QPushButton::menu-indicator{ width:0px; }; 
Adrian Mole
  • 49,934
  • 160
  • 51
  • 83
Nils
  • 11
  • 2