5

My context menu have so many items that i need a slider bar to control it, but i did't find any function could do this. How could i do?

user720037
  • 53
  • 1
  • 3

2 Answers2

9

From another thread on Stack Overflow, I found this trick:

submenu->setStyleSheet("QMenu { menu-scrollable: 1; }");

For further information, see create a scrollbar in a submenu qt?

@Frank Osterfeld: I have a perfect example of a valid use case for huge contextual menu that needs a scrollbar, Qt Creator and the auto-completion list.

Community
  • 1
  • 1
Emma Michelet
  • 197
  • 2
  • 6
0

Menus don't have scrollbars. The style and behavior of (context) menus is defined by OS X, Windows, KDE/Gnome etc., and to my knowledge none of them include scrollbars. Sometimes the menu wraps if it doesn't fit the screen, which is already annoying. Scrollbars in a context menu would be even more unusable. A context menu is just not the right place for such a huge amount of items, and you should redesign your application accordingly.

Frank Osterfeld
  • 24,815
  • 5
  • 58
  • 70