简体   繁体   English

在Qt中为应用禁用“开始听写”

[英]Disable “Start Dictation” for an app in Qt

Is there a way to disable "Start Dictation" for a mac application? 有没有办法为Mac应用程序禁用“启动听写”功能? Basically, I am getting "Start Dictation..." menu in "Edit" Menu bar repeatedly. 基本上,我在“编辑”菜单栏中反复出现“开始听写...”菜单。 Any work around will be helpful. 周围的任何工作都将有所帮助。

Changing the title property of your QMenu will prevent OS X from auto-adding silly things to your Edit menu. 更改QMenu的title属性将阻止OS X将愚蠢的东西自动添加到“编辑”菜单中。

So if I have a QMenuBar and I'm adding menus to it.. 因此,如果我有QMenuBar并向其中添加菜单。

m_edit = this->addMenu(tr(" Edit"));

Notice I put a space in front of the text. 注意,我在文本前面放置了一个空格。

You need to rename your menus to stop macOS messing with them. 您需要重命名菜单以阻止macOS混乱它们。 Adding a space in front of the menu item works, but it is a bit ugly. 在菜单项的前面添加一个空格是可行的,但这有点难看。 This is a classier way to do it using a zero width character: 这是使用零宽度字符的一种更经典的方法:

menu->setTitle( menu->title().prepend( QString::fromUtf8( "\u200C" )  ) );

You can do it for all your top-level application menus like this in your QMainWindow derived class (tested on Qt 4.7): 您可以在QMainWindow派生类中对所有此类顶级应用程序菜单执行此操作(已在Qt 4.7上测试):

#ifdef Q_OS_MACX
foreach ( QMenu* menu, menuBar()->findChildren<QMenu*>() )
{
    menu->setTitle( menu->title().prepend( QString::fromUtf8( "\u200C" )  ) );
}
#endif

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 qt 添加库后应用程序在启动时崩溃 - qt app crash on start after adding a library 当Qt5Core.dll在app目录中时,QT 5.2 app无法启动(错误分配错误) - QT 5.2 app cannot start (Bad allocation error) when Qt5Core.dll is in app directory Qt Android 应用程序因“无法启动活动 GrantPermissionsActivity”而崩溃 - Qt Android app crashes with “Unable to start activity GrantPermissionsActivity” 启动时崩溃 qt 5.15 app(armv8a build) in Android 5.1 - Crash on start qt 5.15 app(armv8a build) in Android 5.1 QT Android应用程序应该在android启动日志之后启动 - QT Android app should start just after android boot log 为什么 Qt Webassembly 应用程序启动时间过长? - Why does Qt Webassembly app start too long? 在Qt 4.8.0中使用OpenCV 2.3.1时,应用程序在启动时崩溃 - App crashes at start when using OpenCV 2.3.1 in Qt 4.8.0 qt creator 3.6(从源代码构建)在构建任何qt app项目时无法启动进程qmake - qt creator 3.6 (build from source) cannot start process qmake when build any qt app project 系统启动后,使用Qt为Android设备开发的自动启动应用程序崩溃 - An auto-start app which is developed with Qt for Android device crashes after the system start up 在 Qt 中禁用 setGraphicsEffect 继承 - Disable setGraphicsEffect inheritance in Qt
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM