简体   繁体   English

如何指定Qt插件构造函数?

[英]how to specify Qt plugin constructor?

I wonder if it is possible to specify a constructor in a Qt plugin interface? 我想知道是否可以在Qt插件界面中指定构造函数? (extending an app) (扩展应用程序)

I want to force the plugins using the interface to take a parameter in the constructor. 我想使用接口强制插件在构造函数中获取参数。

I don't think that it's possible to do exactly what you described. 我认为不可能完全按照你的描述去做。

However, you might try to create factory object and then pass parameters to YourFactory::create() method, which returns pointer to YourObject. 但是,您可能尝试创建工厂对象,然后将参数传递给YourFactory :: create()方法,该方法返回指向YourObject的指针。 Another (uglier IMHO) way is to add initialize() method to YourObject. 另一种(丑陋的IMHO)方法是向YourObject添加initialize()方法。 Check interfaces of QFontEnginePlugin and QScriptExtensionPlugin for both approaches. 检查两种方法的QFontEnginePluginQScriptExtensionPlugin接口。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM