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. Load a .so object with QLibrary from PyQt
Forum Updated to NodeBB v4.3 + New Features

Load a .so object with QLibrary from PyQt

Scheduled Pinned Locked Moved Unsolved General and Desktop
14 Posts 2 Posters 3.8k Views 1 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.
  • J jsulm
    7 Jun 2017, 10:55

    @ilian In any case you should print out the output of errorString() to get more information next time it fails.

    I Offline
    I Offline
    ilian
    wrote on 7 Jun 2017, 11:13 last edited by
    #5

    @jsulm Are you aware of PyQt, it resolved my init function with some sip.voidptr thing, that I don't know how to call. Originally I'd get a C function pointer but this sip.voidptr is not callable.

    J 1 Reply Last reply 7 Jun 2017, 11:15
    0
    • I ilian
      7 Jun 2017, 11:13

      @jsulm Are you aware of PyQt, it resolved my init function with some sip.voidptr thing, that I don't know how to call. Originally I'd get a C function pointer but this sip.voidptr is not callable.

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 7 Jun 2017, 11:15 last edited by jsulm 6 Jul 2017, 11:18
      #6

      @ilian What init function do you mean? Is it a function from your library? If so then sip.voidptr probably means that it could not resolve the function.
      See http://doc.qt.io/qt-5.9/qlibrary.html#resolve, you need to export your functions to be able to resolve them.

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

      I 1 Reply Last reply 7 Jun 2017, 12:19
      0
      • J jsulm
        7 Jun 2017, 11:15

        @ilian What init function do you mean? Is it a function from your library? If so then sip.voidptr probably means that it could not resolve the function.
        See http://doc.qt.io/qt-5.9/qlibrary.html#resolve, you need to export your functions to be able to resolve them.

        I Offline
        I Offline
        ilian
        wrote on 7 Jun 2017, 12:19 last edited by
        #7

        @jsulm I have an init function

        extern "C" int init(int argc, char **argv)
        {
            QApplication a(argc, argv);
            MyWidget w;
            w.init();
            return  a.exec();
        }
        

        resolve() returns a non null value, which is sip.voidptr, and I am expecting this to be a C function pointer but, I have no idea how to call it.

        J 1 Reply Last reply 7 Jun 2017, 12:23
        0
        • I ilian
          7 Jun 2017, 12:19

          @jsulm I have an init function

          extern "C" int init(int argc, char **argv)
          {
              QApplication a(argc, argv);
              MyWidget w;
              w.init();
              return  a.exec();
          }
          

          resolve() returns a non null value, which is sip.voidptr, and I am expecting this to be a C function pointer but, I have no idea how to call it.

          J Offline
          J Offline
          jsulm
          Lifetime Qt Champion
          wrote on 7 Jun 2017, 12:23 last edited by jsulm 6 Jul 2017, 12:27
          #8

          @ilian Please take a look at the link I posted before: you need to export your function, else it cannot be resolved.

          You are aware that a.exec() will block until you close your app? That means init() call will block.

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

          I 1 Reply Last reply 7 Jun 2017, 12:32
          1
          • J jsulm
            7 Jun 2017, 12:23

            @ilian Please take a look at the link I posted before: you need to export your function, else it cannot be resolved.

            You are aware that a.exec() will block until you close your app? That means init() call will block.

            I Offline
            I Offline
            ilian
            wrote on 7 Jun 2017, 12:32 last edited by
            #9

            @jsulm I am aware yes, removed it, and just show the widget. However, I did the example with MY_EXPORT macro, I still get this voidptr. I will test in C++ program to see if there everything is OK.

            J 1 Reply Last reply 7 Jun 2017, 12:35
            0
            • I ilian
              7 Jun 2017, 12:32

              @jsulm I am aware yes, removed it, and just show the widget. However, I did the example with MY_EXPORT macro, I still get this voidptr. I will test in C++ program to see if there everything is OK.

              J Offline
              J Offline
              jsulm
              Lifetime Qt Champion
              wrote on 7 Jun 2017, 12:35 last edited by
              #10

              @ilian This void pointer is valid, but I don't know how to use it if it points to a function. Never did this with PyQt.

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

              I 1 Reply Last reply 7 Jun 2017, 12:53
              0
              • J jsulm
                7 Jun 2017, 12:35

                @ilian This void pointer is valid, but I don't know how to use it if it points to a function. Never did this with PyQt.

                I Offline
                I Offline
                ilian
                wrote on 7 Jun 2017, 12:53 last edited by
                #11

                @jsulm I've made a similar C++ program with the function pointer, and it does what I want, open a widget and enters it's event loop. In short, as C++ program, loading the library everything is fine, as PyQt - it's not, or the reslove form PyQt and that sip.voidptr are some weird stuff, we know not of.

                J 1 Reply Last reply 8 Jun 2017, 05:08
                0
                • I Offline
                  I Offline
                  ilian
                  wrote on 7 Jun 2017, 14:21 last edited by
                  #12

                  libc = CDLL('/home/ilian/git-projects/build-testpyqtlib-Desktop_Qt_5_7_1_GCC_64bit-Debug/libtestpyqtlib.so') That line of code solved it all, just called libc.init(0, 0) and the widget from the lib appeared...

                  1 Reply Last reply
                  0
                  • I ilian
                    7 Jun 2017, 12:53

                    @jsulm I've made a similar C++ program with the function pointer, and it does what I want, open a widget and enters it's event loop. In short, as C++ program, loading the library everything is fine, as PyQt - it's not, or the reslove form PyQt and that sip.voidptr are some weird stuff, we know not of.

                    J Offline
                    J Offline
                    jsulm
                    Lifetime Qt Champion
                    wrote on 8 Jun 2017, 05:08 last edited by
                    #13

                    @ilian said in Load a .so object with QLibrary from PyQt:

                    sip.voidptr

                    this is not weird stuff :-)
                    It is documented, I just don't know how to use it if it contains a function pointer - I could not find anything in SIP documentation for this use case.

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

                    I 1 Reply Last reply 12 Jun 2017, 12:03
                    0
                    • J jsulm
                      8 Jun 2017, 05:08

                      @ilian said in Load a .so object with QLibrary from PyQt:

                      sip.voidptr

                      this is not weird stuff :-)
                      It is documented, I just don't know how to use it if it contains a function pointer - I could not find anything in SIP documentation for this use case.

                      I Offline
                      I Offline
                      ilian
                      wrote on 12 Jun 2017, 12:03 last edited by
                      #14

                      @jsulm Yes, same here, I don't know how to solve that problem, I was expecting a better examples how to make it the C way here, alas none was present.

                      1 Reply Last reply
                      0

                      14/14

                      12 Jun 2017, 12:03

                      • Login

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