Solved PyQt loading libraries, what is wrong there?
-
Hi,
Not a direct answer but wouldn't it be simpler to create bindings the same way PyQt does for your custom set of widgets ?
-
@SGaist I am really not a python/PyQt expert, so I have no idea about how to do that, but I will do some research, thanks.
-
Take a look here. PyQt uses sip to create the bindings. At the bottom of the page you can find an Qt example.
-
@SGaist I don't want to deal with that SIP thing, I want to keep as Qt as possible for the other team members. I was able to use
QPluginLoader
and get aQObject
instance in the damnedPyQt
, however I am stuck with the lacking ofqobject_cast<>
which can cast to the interface, and I have no idea how to implement the classicC++
interface in thePyQt
thing. Also the internet lacks any sophisticated info :( -
What I came into my mind, which can be considered an ugly hack, it to dump a
QWidget
to a char array, then cast it toQWidget
again usingC
unionunion WidgetData { QWidget w; char data[sizeof(QWidget)]; };
but even then, I can't cast anything ... Really, I don't want to bother with that SIP thing, I want to keep it as simple as possible, and there must be some way, I'll try with
Python.h
to see if cant be done there, but this is really frustrating fromPyQt
side, not to have a simple example for theQLibrary
andQPLuginLoader
.... -
@ilian "I don't want to deal with that SIP thing" - do you think it is better to hack around with manual library loading and some dirty hacks like the union? PyQt already provides nice Qt integration in Python using SIP - it would be better to do it in the same way.
-
@jsulm It's a huge task I can't handle the whole task writing over 200 classes in that SIP modules. What I want is just to bridge existing slots in a C++ program to a PyQt based program, so the PyQto to be able to send signal/slots to the C++ program. That's why I want to be able to extract an Qt stuff from the library, which is C++. If I go into the SIP thing I will be totally lost.
-
Also the examples are all for
PyQt4
, and I am usingPyQt5
that leads me to even further obfuscation. -
I am trying
PyQt4
example in the SIP site, it fails me building a Qt module. Even with a copy/pasted code it gives me missingsbf
files and cannot findQtGui\QtGuimod.sip
. I don't know how people deal with this thing anymore. -
I was able to fight trough the SIP, if somebody needs an example: here it is:
https://github.com/heatblazer/pyqtlibtest/tree/master/sip@SGaist thanks for the referal, it was a hard task but there is no way around.
@jsulm Seems like I could not avoid SIP :(