1

How does one build a custom widget in Qt/C++ (version 5.5) that loads the native OSX webkit? I read this tutorial but need to do something more powerful because Qt doesn't already contain the native webkit.

Qt 5.5 has a "tech preview" for the native webkit, but it's buggy -- when you load form controls, they appear all wonky.

I've taught myself some Objective C. So, I was wondering if I had to build something in Objective C and then somehow load it inside Qt/C++?

Or, perhaps I can build the interface in Objective C and then have it call Qt/C++?

Ultimately, here's what I want:

  • Uses native OSX webkit, not the one bundled with Qt, not the tech preview.

  • Embeds a link to my Qt/C++ class in Javascript. So, I can do something like: var sFileSelection = cpp.selectFile('*.txt'); and it calls a Qt class method selectFile(QString sFile) to do work such as show a popup select file window, and then Javascript receives this back in sFileSelection.

Community
  • 1
  • 1
Volomike
  • 23,743
  • 21
  • 113
  • 209
  • You can't just pull Safari into a Qt app, they publish WebKit but it's not in a manner that can be dropped in. – Nicholas Smith Dec 04 '15 at 21:48
  • @NicholasSmith You may not have seen [this](https://el-tramo.be/blog/mixing-cocoa-and-qt/) and [this](https://github.com/mikemcquaid/Qocoa#readme). So -- yes, it's possible to build a Qt/C++ wrapper for Cocoa widgets. I just don't know the technique yet for the webkit one. – Volomike Dec 04 '15 at 21:54
  • 1
    I have previously seen, and used, those examples, but WebKit on OS X isn't an available and easily convertible library, otherwise people would have already solved it. – Nicholas Smith Dec 05 '15 at 00:56
  • Thanks for that info! – Volomike Dec 05 '15 at 04:40

1 Answers1

0

The better solution that has been proposed is to develop the app's GUI in Objective C, and then call a Qt/C++ Dylib (the equivalent of a DLL on Windows) from the Objective C to do the heavy-lifting. (Assuming you prefer to do most of the coding in Qt.) The drawback of the Qt Dylib is that it cannot draw GUI components or show things like a file dialog because it has no application context handle to use for such things. Therefore, those GUI things must be called from ObjectiveC. However, one can have the class method in Qt and then it can send a message back to ObjectiveC to call one of its own class methods.

As for how to load a Dylib created with Qt inside an Objective C application, that's another question entirely.

Community
  • 1
  • 1
Volomike
  • 23,743
  • 21
  • 113
  • 209