[英]Why does my Qt app ignore the setting of applicationDisplayName?
I am running a small app on KDE Plasma 5 created with Qt and the KDE framework. 我正在使用Qt和KDE框架创建的KDE Plasma 5上运行一个小型应用程序。 Almost everything works like a charm, just one part doesn't work.
几乎所有事物都像魅力一样起作用,只有一部分不起作用。 I just cannot set the application display name.
我只是无法设置应用程序的显示名称。 I have the following code:
我有以下代码:
int main(int argc, char **argv) { QApplication application(argc, argv); KLocalizedString::setApplicationDomain("blender-render-control"); KCrash::initialize(); KAboutData aboutData(QStringLiteral("blender-render-control-center"), i18n("Blender Render Control Center"), QStringLiteral("1.0"), i18n("A simple application to control the blender render control server"), KAboutLicense::Custom, i18n("Copyright 2019, Knerd ")); aboutData.addAuthor(i18n("Knerd"), i18n("Author"), QStringLiteral("knerd@knerd.knerd")); aboutData.setOrganizationDomain("knerd.knerd"); aboutData.setDesktopFileName(QStringLiteral("knerd.knerd.blender-render-control")); KAboutData::setApplicationData(aboutData); QApplication::setWindowIcon(QIcon::fromTheme(QStringLiteral("knerd.knerd.blender-render-control"))); application.setApplicationDisplayName(i18n("Blender Render Control Center")); application.setApplicationName(i18n("Blender Render Control Center")); QCommandLineParser parser; aboutData.setupCommandLine(&parser); parser.process(application); aboutData.processCommandLine(&parser); auto *window = new MainWindow(); window->show(); return QApplication::exec(); }
From reading the docs and checking some examples, this should set the application title in my KDE environment. 通过阅读文档并检查一些示例,这应该在我的KDE环境中设置应用程序标题。 But it doesn't, the application name is the name of the executable.
但是不是,应用程序名称是可执行文件的名称。
Is this a bug in KDE or am I doing something wrong? 这是KDE中的错误,还是我做错了什么?
The docs are a bit confusing on what the applicationName and displayApplicationName are actually used for, there has been some bug reports about it, and behavior has changed between versions if I remember correcly. 这些文档对于applicationName和displayApplicationName的实际用途有些困惑,有一些关于它的错误报告,并且如果我记得的话,版本之间的行为也有所变化。
If you want a window-title, I think you can do. 如果您想要窗口标题,我想您可以。
window->setWindowTitle( QCoreApplication::applicationName() );
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.