Qt。当从插件调用 QDialog 时,从任务栏隐藏 QDialog

发布于 2025-01-03 05:07:04 字数 368 浏览 2 评论 0原文

我开发了一个带有插件的应用程序。每个插件应该有它自己的设置窗口(QDialog 类型)。

如果插件的设置表单包含在主项目中,我将简单地通过传递主表单作为父表单来创建它,如下所示: http://developer.qt.nokia.com/doc/qt-4.8/qdialog.html#QDialog(以及此问题的 Google 结果)。

但是当 QDialog 在单独的插件中声明时,我认为将主窗体作为父级从主应用程序传递到插件实例是丑陋且不安全的。

有什么想法吗?存根QWidget?

I develop an app with plugins. Each plugin should have it's own settings window (QDialog type).

If plugin's settings form was included in main project, I'll simply create it with passing main form as parent as said here: http://developer.qt.nokia.com/doc/qt-4.8/qdialog.html#QDialog (and in Google results for this problem).

But when QDialog declared in separated plugin, I think that it's ugly and insecure to pass main form as parent from main app to plugin instance.

Any ideas? Stub QWidget?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

十二 2025-01-10 05:07:04

我有一个小想法。这是不同的方法,但它也可能适用于您的情况。据我了解,您正在尝试为您的应用程序创建设置管理器。例如,您可以使用 QSettings 并将每个插件的设置存储在不同的子组中。例如,您有一个主应用程序设置和两个其他插件。

[Main App]
key1=val1
key2=val2

[Plugin1]
key1=val1
key2=val2

[Plugin1]
key1=val1
key2=val2

这样您就可以在主应用程序中轻松构建QDialog并更改/保存设置。反过来,主应用程序通过信号通知插件设置已更改并且需要重新加载。通过这种方式,您可以从插件中封装主应用程序。

更新

感谢您的快速反馈。我提出的方法是以 MainApplication 为中心的,但可以重新设计为去中心化。由于 QSettings 是特定于应用程序的,您的插件可以像以前一样将其设置存储在主应用程序的一个配置中。我要做的一项修改如下。您可以在插件中创建一个QDialog并修改设置,而无需主应用程序知道此过程。

I have a small idea. This is different approach but it might work in your case too. As I understand you are trying to create settings manager for you application. You can use QSettings for example and store settings for each plugin in different subgroup. For example you have a main app settings and two other plugins.

[Main App]
key1=val1
key2=val2

[Plugin1]
key1=val1
key2=val2

[Plugin1]
key1=val1
key2=val2

This way you could easily construct a QDialog in your main appication and change/save the settings. In turn the main application notifies plugins via signal that settings have changed and need to be reloaded. This way you encapsulate you main application from your plugins.

update

Thanks for a quick feedback. The approach I proposed is MainApplication centric but it can be redesigned to be decentralized. Since QSettings is application specific your plugins can store their settings in one configuration with main app as before. One modification I would make is the following. You can create a QDialog within your plugin and modify the settings without necessity for main app to be aware of this process.

守护在此方 2025-01-10 05:07:04

好的,我只是按照之前的建议创建存根 QWidget:

QWidget *a = new QWidget();
settingsForm = new OpenFolderSettings(a);
...
delete settingsForm;
delete a;

所以现在对话框在任务栏上不显示按钮。此外,没有出现新窗口。

Ok, I'd just create stub QWidget as suggest earlier:

QWidget *a = new QWidget();
settingsForm = new OpenFolderSettings(a);
...
delete settingsForm;
delete a;

So now dialog doesn't show button on taskbar. Also, no new window appear.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文