开发者

Qt on Mac -- how to access "search" in help menu

I am porting my Qt app to Mac OS X. On Windows/Linux I've used a QLineEdit to provide a search feature in the Help menu.

In Mac OS X, I saw something like this is built-in:

Qt on Mac -- how to access "search" in help menu

How can I acces开发者_开发知识库s this search bar with Qt (i.e., add my own elements to it)? I looked at QMenuBar in the docs but couldn't find anything relevant. If it's not possible, can I at least use some native API from my C++ Qt app?

Thanks a lot.


This is the Spotlight For Help search field, which is entirely controlled by the system. It automatically provides results from your application's Help Book and menu items. AFAIK you can't populate it "manually". It works automatically when you create a Help Book for your application.

See Apple Help Concepts: The Help Menu.


It seems you can't do this directly through Qt, however, you can implement this one feature in Objective-C++/Cocoa.

It is possible through the - registerUserInterfaceItemSearchHandler method of NSApplication to register a custom function for querying and returning search items.

QtHelp seems to have support for automatic indexing, which means you can delegate search to that.


If you add a Help menu to your application, Qt will automatically add the search box. See http://doc.qt.io/qt-4.8/mac-differences.html#menu-bar


You can get rid of the Search menu Mac OSX adds to Help menus simply by calling the menu something else. Just adding a space:

QMenu *helpMenu = menuBar()->addMenu(" Help"));

will work.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜