Qt。当从插件调用 QDialog 时,从任务栏隐藏 QDialog
我开发了一个带有插件的应用程序。每个插件应该有它自己的设置窗口(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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我有一个小想法。这是不同的方法,但它也可能适用于您的情况。据我了解,您正在尝试为您的应用程序创建设置管理器。例如,您可以使用 QSettings 并将每个插件的设置存储在不同的子组中。例如,您有一个主应用程序设置和两个其他插件。
这样您就可以在主应用程序中轻松构建
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.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 aQDialog
within your plugin and modify the settings without necessity for main app to be aware of this process.好的,我只是按照之前的建议创建存根 QWidget:
所以现在对话框在任务栏上不显示按钮。此外,没有出现新窗口。
Ok, I'd just create stub QWidget as suggest earlier:
So now dialog doesn't show button on taskbar. Also, no new window appear.