简体   繁体   English

Qt 插件能否更改主应用程序创建的 UI?

[英]Could a Qt plugin change the UI created by main application?

I build a main Qt application to load model files(some kind of 3d models files like STL).我构建了一个主要的 Qt 应用程序来加载 model 文件(某种 3d 模型文件,如 STL)。 And then I leverage a tree widget to show the loaded file's information.然后我利用树小部件来显示加载文件的信息。 Then I build a Qt plugin to modify the loaded files.然后我构建了一个 Qt 插件来修改加载的文件。

Could I refresh the tree UI created in main application when I have completed editing file in the plugin?当我在插件中完成编辑文件后,是否可以刷新在主应用程序中创建的树 UI? or, How could the plugin communicate with the main application,(for example tell main application that its data has been modified and it should refresh its UI )?或者,插件如何与主应用程序通信(例如告诉主应用程序它的数据已被修改,它应该刷新它的 UI)?

I finally use signal/slot solve the problem.我终于用信号/槽解决了这个问题。 First I build a common lib that are known by both main application and the plugin.首先,我构建了一个主应用程序和插件都知道的公共库。 Then I define a signal(which will be emitted when the UI should be changed) in the common lib and connect it with slot defined in the main application.然后我在公共库中定义了一个信号(当 UI 应该改变时会发出),并将它与主应用程序中定义的插槽连接起来。 After that, when I change the data by plugins I will let the common lib send the signal and the main UI could be changed.之后,当我通过插件更改数据时,我会让公共库发送信号,并且可以更改主 UI。
Why not sending signal in plugins?为什么不在插件中发送信号? Because I can't find a way connect signals in plugins with slot in main applications directlly.因为我找不到直接将插件中的信号与主要应用程序中的插槽连接的方法。 I hope that I have explained this well and there are other possible solutions.我希望我已经很好地解释了这一点,并且还有其他可能的解决方案。

暂无
暂无

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

相关问题 我可以在QT中更改主应用程序的图标大小吗? - Could I change the icon size of main application in QT? 如何在Qt中的插件和主应用程序之间通信? - How to communicate between plugin and main application in Qt? Qt5:从插件中调用主应用程序功能 - Qt5: Call main-application functions from within a plugin 在Mac上部署Qt应用程序:此应用程序无法启动,因为它无法在“”中找到或加载Qt平台插件“ cocoa” - Deploying a Qt application on Mac: This application failed to start because it could not find or load the Qt platform plugin “cocoa” in “” (Qt 5.4.1) 此应用程序无法启动,因为它无法找到或加载 Qt 平台插件“xcb” - (Qt 5.4.1) This application failed to start because it could not find or load the Qt platform plugin “xcb” 如何在 qt 中从 main.cpp 更改我的 ui 对象? - How can I change my ui object from main.cpp in qt? 在Qt中更改主窗口标题 - Change main window title in Qt 应用程序无法启动,因为它无法找到或加载QT平台插件“windows” - Application failed to start because it could not find or load the QT platform plugin “windows” 此应用程序无法启动,因为它无法找到或加载Qt平台插件“windows”错误消息 - This application failed to start because it could not find or load the Qt platform plugin “windows” error message 此应用程序无法启动,因为无法找到或加载Qt平台插件“ xcb” - This application failed to start because it could not find or load the Qt platform plugin “xcb”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM