Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. PyQt loading libraries, what is wrong there?
Forum Updated to NodeBB v4.3 + New Features

PyQt loading libraries, what is wrong there?

Scheduled Pinned Locked Moved Solved General and Desktop
11 Posts 3 Posters 4.8k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by
    #2

    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 ?

    Interested in AI ? www.idiap.ch
    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

    I 1 Reply Last reply
    0
    • SGaistS SGaist

      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 ?

      I Offline
      I Offline
      ilian
      wrote on last edited by
      #3

      @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.

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #4

        Take a look here. PyQt uses sip to create the bindings. At the bottom of the page you can find an Qt example.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        I 1 Reply Last reply
        0
        • SGaistS SGaist

          Take a look here. PyQt uses sip to create the bindings. At the bottom of the page you can find an Qt example.

          I Offline
          I Offline
          ilian
          wrote on last edited by
          #5

          @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 a QObject instance in the damned PyQt, however I am stuck with the lacking of qobject_cast<> which can cast to the interface, and I have no idea how to implement the classic C++ interface in the PyQt thing. Also the internet lacks any sophisticated info :(

          1 Reply Last reply
          0
          • I Offline
            I Offline
            ilian
            wrote on last edited by
            #6

            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 to QWidget again using C union

            union 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 from PyQt side, not to have a simple example for the QLibrary and QPLuginLoader....

            jsulmJ 1 Reply Last reply
            0
            • I ilian

              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 to QWidget again using C union

              union 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 from PyQt side, not to have a simple example for the QLibrary and QPLuginLoader....

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #7

              @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.

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              I 1 Reply Last reply
              0
              • jsulmJ jsulm

                @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.

                I Offline
                I Offline
                ilian
                wrote on last edited by
                #8

                @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.

                1 Reply Last reply
                0
                • I Offline
                  I Offline
                  ilian
                  wrote on last edited by
                  #9

                  Also the examples are all for PyQt4 , and I am using PyQt5 that leads me to even further obfuscation.

                  1 Reply Last reply
                  0
                  • I Offline
                    I Offline
                    ilian
                    wrote on last edited by
                    #10

                    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 missing sbf files and cannot find QtGui\QtGuimod.sip . I don't know how people deal with this thing anymore.

                    1 Reply Last reply
                    0
                    • I Offline
                      I Offline
                      ilian
                      wrote on last edited by
                      #11

                      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 :(

                      1 Reply Last reply
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved