简体   繁体   English

Qt可以显示OSX dylib中的OSX Finder选择文件对话框(QFileDialog :: getOpenFileName)吗?

[英]Can Qt show OSX Finder Choose File Dialog (QFileDialog::getOpenFileName) from an OSX dylib?

I'm making a Qt/C++ dylib on OSX. 我正在OSX上制作Qt / C ++ dylib。 How can I get it to call QFileDialog::getOpenFileName() when there is no widget context? 没有窗口小部件上下文时,如何调用QFileDialog :: getOpenFileName()?

(Background: See, what I'm doing here is building a minimalist Objective C Cocoa application that will load my Qt/C++ dylib to do most of the work. This allows me to use the OSX native webkit (something not provided by Qt/C++ in 5.5). I prefer working in Qt/C++ than Objective C. So, that's why I'm interested.) (背景:看,我在这里正在做的是构建一个极简的Objective C Cocoa应用程序,该应用程序将加载我的Qt / C ++ dylib来完成大部分工作。这使我可以使用OSX本机Webkit(Qt / 5.5中的C ++)。我比在Objective C中更喜欢在Qt / C ++中工作。因此,这就是我感兴趣的原因。)

The answer according to Simon Warta and Nicholas Smith is no -- it requires a widget context in Qt to drive that dialog from Qt. Simon Warta和Nicholas Smith的答案是否定的-它需要Qt中的小部件上下文才能从Qt驱动该对话框。 Since there isn't one in this case, I would have to drive certain tasks, which require such a context, from Objective C instead. 由于在这种情况下没有人,所以我将不得不从目标C驱动某些需要这种上下文的任务。 However, Nicholas Smith also says that it's a better programming strategy to drive the GUI from Objective C in such a case, and drive the rest from Qt/C++ for the heavy lifting tasks such as database stuff, etc. 但是,尼古拉斯·史密斯(Nicholas Smith)还说,在这种情况下,从目标C驱动GUI,然后从Qt / C ++驱动其余的任务来完成繁重的任务(例如数据库工作)是一种更好的编程策略。

Since I'm building a project that uses Webkit mostly for the GUI and may only need something minor outside that for GUI, such as open a Finder file dialog, it's actually not going to be that much Objective C. The rest I can drive from Qt/C++, since I prefer that more. 由于我正在建立一个主要将Webkit用于GUI的项目,并且可能只需要GUI之外的一些小东西,例如打开Finder文件对话框,因此实际上并不需要那么多的ObjectiveC。其余的我可以从Qt / C ++,因为我更喜欢。

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

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