Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Language Bindings
  4. python + qt
Forum Updated to NodeBB v4.3 + New Features

python + qt

Scheduled Pinned Locked Moved Solved Language Bindings
8 Posts 2 Posters 3.2k 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.
  • U Offline
    U Offline
    user4592357
    wrote on last edited by
    #1

    hi again, forum!

    i wanna write a program in c++ (using qt, of course) but for some part of the program i find python more efficient. how can i mix these 2 language codes?

    (pyqt? i know about it, i'm just curious about this language mix version)

    JonBJ 1 Reply Last reply
    0
    • U user4592357

      hi again, forum!

      i wanna write a program in c++ (using qt, of course) but for some part of the program i find python more efficient. how can i mix these 2 language codes?

      (pyqt? i know about it, i'm just curious about this language mix version)

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @user4592357
      If you have decided that you want to write the Qt stuff in C++, you won't be using PyQt, and it becomes a question of how to call bits in Python from your C++ app?

      U 1 Reply Last reply
      0
      • JonBJ JonB

        @user4592357
        If you have decided that you want to write the Qt stuff in C++, you won't be using PyQt, and it becomes a question of how to call bits in Python from your C++ app?

        U Offline
        U Offline
        user4592357
        wrote on last edited by
        #3

        @JNBarchan

        i know that i can't use pyqt in my c++ + qt app. i meant, i can just use pyqt. but no. i don't want that

        and what is bits?

        JonBJ 1 Reply Last reply
        0
        • U user4592357

          @JNBarchan

          i know that i can't use pyqt in my c++ + qt app. i meant, i can just use pyqt. but no. i don't want that

          and what is bits?

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by JonB
          #4

          @user4592357
          Are you expecting an answer that has anything to do with Qt? Or are you expecting an answer about how to call Python code from C++ code, or even C++ from Python?

          U 1 Reply Last reply
          0
          • JonBJ JonB

            @user4592357
            Are you expecting an answer that has anything to do with Qt? Or are you expecting an answer about how to call Python code from C++ code, or even C++ from Python?

            U Offline
            U Offline
            user4592357
            wrote on last edited by
            #5

            @JNBarchan

            sorry, i didn't quite well mention that.

            so, as i said the main app is in c++ and for gui i'm using qt, and i need to call python code from my c++ code. the python code will take some qt component as its argument and do its job based on that component data. i hope this is clear

            JonBJ 2 Replies Last reply
            0
            • U user4592357

              @JNBarchan

              sorry, i didn't quite well mention that.

              so, as i said the main app is in c++ and for gui i'm using qt, and i need to call python code from my c++ code. the python code will take some qt component as its argument and do its job based on that component data. i hope this is clear

              JonBJ Offline
              JonBJ Offline
              JonB
              wrote on last edited by
              #6

              @user4592357 said in python + qt:

              the python code will take some qt component as its argument and do its job based on that component data.

              Ah! Now you're saying you're going to write the UI/Qt side in C++, but you still want to pass Qt objects etc. on to Python code, and act on them there. But you don't want to use PyQt.

              Then good luck! Because it seems to me PyQt is a great big library of code precisely to make Qt stuff accessible from Python. So if you're going to do that yourself, you'll want to reimplement all the code & ideas there for your purposes.

              1 Reply Last reply
              2
              • U user4592357

                @JNBarchan

                sorry, i didn't quite well mention that.

                so, as i said the main app is in c++ and for gui i'm using qt, and i need to call python code from my c++ code. the python code will take some qt component as its argument and do its job based on that component data. i hope this is clear

                JonBJ Offline
                JonBJ Offline
                JonB
                wrote on last edited by
                #7

                @user4592357
                To summarise, from what you describe, I believe you have 4 choices. I see them in the following order of desirability/simplicity (best to worst):

                1. Stick to one language, either C++ or Python. If you do want to use Python, you can do anything at the Qt/UI side via PyQt which you could do "natively" via C++, so it is not obvious that C++ would be the only choice for Qt interface.

                2. If you must mix languages, do everything to do with Qt/UI in your C++ side, and don't pass anything Qt to/from Python.

                3. If you must mix languages and you have to have your Python side aware of the UI side, make an abstraction of the Qt stuff such that the C++ passes only what is relevant extracted from the Qt to Python, and similarly the Python can alter that intermediate layer and then the C++ turns it back into Qt calls. This means that no Qt objects/calls are passed across the languages.

                4. Finally, your idea of mixing the two languages and passing Qt stuff around. I don't know what you will do about accessing Qt from the Python side, given that you don't have the logic of PyQt which handles Qt from Python.

                That's my opinion!

                1 Reply Last reply
                0
                • U Offline
                  U Offline
                  user4592357
                  wrote on last edited by
                  #8

                  what i was describing, fits your 3rd point more.

                  i would want to use c++ but for some part of the program, python does the job better than c++ that's why i also need python

                  but maybe 1st point is good too. only pyqt

                  1 Reply Last reply
                  1

                  • Login

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