开发者

How to add an slider bar into QMenu?

开发者 https://www.devze.com 2023-02-28 14:37 出处:网络
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?From another thread on Stack Overflow, I found

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?


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消