简体   繁体   中英

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

I'm making a Qt/C++ dylib on OSX. How can I get it to call QFileDialog::getOpenFileName() when there is no widget context?

(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.)

The answer according to Simon Warta and Nicholas Smith is no -- it requires a widget context in Qt to drive that dialog from 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. 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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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