Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c++

macos

qt

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: enter image description here

How can I access 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.

like image 376
houbysoft Avatar asked Jul 13 '11 03:07

houbysoft


3 Answers

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.

like image 66
deceze Avatar answered Sep 18 '22 18:09

deceze


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.

like image 30
Symaxion Avatar answered Sep 20 '22 18:09

Symaxion


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

like image 27
koan Avatar answered Sep 19 '22 18:09

koan