1

I wanted to know if the language bindings for Qt like Qt Jambi and PyQt have implemented all of the Qt modules or not. i.e. whether they are just a means of combining target languages (JAVA, python,...) with Qt C++ modules or the target languages work with the modules implemented with the target language.

e.g. a simple question is: Does Qt Jambi work with Qt modules written in Java? (If yes, could we write Qt Jambi applications which are able to run in different platforms? i.e. Are all Qt Jambi modules some jar files?)

Nejat
  • 31,784
  • 12
  • 106
  • 138
  • Essentially: possible duplicate of [How do language bindings work?](http://stackoverflow.com/questions/4546941/how-do-language-bindings-work) – Jonathon Reinhart Mar 16 '14 at 05:01
  • 1
    @JonathonReinhart: I do not see how that could be a duplicate. It does not answer the Qt specific question. – László Papp Mar 16 '14 at 05:05
  • But asking how PyQt (the Python binding to Qt) is just a specific example of the more generic question, "how to language bindings work"? This is like asking "How does a 60W incandescent light bulb work?" when the question "How does an incandescent light bulb work?" is just as good. – Jonathon Reinhart Mar 16 '14 at 05:07
  • The OP might be interested in the coverage of these bindings, too. That part, at least, would not be general. – László Papp Mar 16 '14 at 05:08
  • If there is something I'm missing, and there's something Qt-specific that the linked question doesn't answer, I will be glad to retract my vote. – Jonathon Reinhart Mar 16 '14 at 05:09
  • @JonathonReinhart: These two questions may just have a little overlap. But they are different. At least i could not get my answer. – Nejat Mar 16 '14 at 05:44

2 Answers2

2

As far as PyQt is concerned, the answer to whether it has "implemented all of the Qt modules or not" is: yes and no. But mostly no.

PyQt uses the SIP tool to generate its bindings. If you want to understand how this is done, here is how the author of PyQt and SIP explains the process:

For PyQt v4 I use an internal tool (written using PyQt of course) called metasip. This is sort of an IDE for SIP. It uses GCC-XML to parse the latest header files and saves the relevant data, as XML, in a metasip project. metasip then does the equivalent of a diff against the previous version of the API and flags up any changes that need to be looked at. Those changes are then made through the GUI and ticked off the TODO list. Generating the .sip files is just a button click. In my subversion repository, PyQt v4 is basically just a 20M XML file. Updating PyQt v4 for a minor release of Qt v4 is about half an hours work.

In terms of how the generated code works then I don't think it's very different from how any other bindings generator works. Python has a very good C API for writing extension modules - it's one of the reasons why so many 3rd party tools have Python bindings. For every C++ class, the SIP generated code creates a corresponding Python class implemented in C.

So PyQt is just a set of fairly thin wrappers around the Qt modules, and generally doesn't implement any functionality itself. However, there are a few exceptions to this.

Firstly, PyQt adds some syntactic sugar in various places to make the Qt APIs a little more palatable for Python coders (for example, the new-style signal and slot support).

Secondly, there are some Qt APIs which it would make no sense for PyQt to provide, due to fundamental language differences between C++ and Python (e.g. there is nothing equivalent to type-casting in Python).

And finally, there is the uic module. Unlike PySide, PyQt doesn't wrap the QtUiTools module at all. Instead, it provides a module written in pure Python that actually does implement the equivalent functionality from the Qt library. But this is the exception, rather than the rule.

In addition to the above, there are undoubtably many other differences and omissions that I haven't covered here (particularly with regard to PyQt5). As with all language bindings, the fundamental aim is to provide a practical means of communication between two languages, rather than a perfect one-to-one mapping.

ekhumoro
  • 115,249
  • 20
  • 229
  • 336
1

They do not have coverage for everything, no. Here is one of my previous answers that shows that PySide was lacking the wrapping of one class.

I had to hand-craft it after realizing it here on Stack Overflow. In general, it highly depends on the authors of the particular Qt binding. Some of them are well-covered, but some are unmaintained for a while.

As for your Qt Jambi and jar question, I am not certain, but at least there is some code-level separation as you can see it in here.

Community
  • 1
  • 1
László Papp
  • 51,870
  • 39
  • 111
  • 135