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. I'm trying to make a Python QT GUI but my files are in c++
Forum Updated to NodeBB v4.3 + New Features

I'm trying to make a Python QT GUI but my files are in c++

Scheduled Pinned Locked Moved Unsolved General and Desktop
10 Posts 2 Posters 723 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.
  • L Offline
    L Offline
    lfreeman6490
    wrote on last edited by
    #1
    This post is deleted!
    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by mrjj
      #2

      Hi
      While you can call c++ from python and reverse I'm not sure what goal is here?
      Do you want to convert app to python or you want the C++ GUi to call a function in python
      as a backend ?

      You can convert the UI file into something useful with python but the .cpp would not be in effect then.

      L 1 Reply Last reply
      0
      • L Offline
        L Offline
        lfreeman6490
        wrote on last edited by
        #3
        This post is deleted!
        mrjjM 1 Reply Last reply
        0
        • mrjjM mrjj

          Hi
          While you can call c++ from python and reverse I'm not sure what goal is here?
          Do you want to convert app to python or you want the C++ GUi to call a function in python
          as a backend ?

          You can convert the UI file into something useful with python but the .cpp would not be in effect then.

          L Offline
          L Offline
          lfreeman6490
          wrote on last edited by
          #4

          @mrjj Both are private entities at the moment, for example.

          In my Python code I have a connect function, and then there is a connect button in the GUI. Once the connect button is hit on the GUI I want to call the connect function. And so on from there.

          1 Reply Last reply
          0
          • L lfreeman6490

            This post is deleted!

            mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @lfreeman6490

            Hi
            Ok.
            option 1:
            convert UI file to python
            https://doc.qt.io/qtforpython/tutorials/basictutorial/uifiles.html

            and use it directly with your python app and leave .cpp and .h in the dust.

            Option 2:
            Keep the app as GUI and call python as a script
            https://forum.qt.io/topic/115475/calling-python-from-qt-c

            Option 3:
            Embed python in the C++ app
            https://docs.python.org/3/extending/embedding.html

            Qustion:
            Does the cpp file do anything ?

            1 Reply Last reply
            1
            • L Offline
              L Offline
              lfreeman6490
              wrote on last edited by lfreeman6490
              #6

              @mrjj The cpp files are very small and mostly contain default constructors and other variable type information. I don't use them for any of the actual code

              mrjjM 1 Reply Last reply
              0
              • L lfreeman6490

                @mrjj The cpp files are very small and mostly contain default constructors and other variable type information. I don't use them for any of the actual code

                mrjjM Offline
                mrjjM Offline
                mrjj
                Lifetime Qt Champion
                wrote on last edited by
                #7

                @lfreeman6490

                Hi
                Well Qt has very good python-support so I think i would use reuse the UI file and
                make the app a pure python app to avoid too much fiddling with mixing c++ and python.

                L 1 Reply Last reply
                0
                • mrjjM mrjj

                  @lfreeman6490

                  Hi
                  Well Qt has very good python-support so I think i would use reuse the UI file and
                  make the app a pure python app to avoid too much fiddling with mixing c++ and python.

                  L Offline
                  L Offline
                  lfreeman6490
                  wrote on last edited by
                  #8

                  @mrjj That would be similar to the first link you sent then correct?

                  mrjjM 1 Reply Last reply
                  0
                  • L lfreeman6490

                    @mrjj That would be similar to the first link you sent then correct?

                    mrjjM Offline
                    mrjjM Offline
                    mrjj
                    Lifetime Qt Champion
                    wrote on last edited by mrjj
                    #9

                    @lfreeman6490

                    Yes
                    The UI file is an XML file that contains positions and properties of the Form/widgets.

                    The pyside6-uic converts this XML file to code and its just like normal python code.

                    you can also load UI files at runtime
                    https://doc.qt.io/qtforpython-5/PySide2/QtUiTools/QUiLoader.html
                    but then its a bit more clumsy to get to talk to them.

                    L 1 Reply Last reply
                    0
                    • mrjjM mrjj

                      @lfreeman6490

                      Yes
                      The UI file is an XML file that contains positions and properties of the Form/widgets.

                      The pyside6-uic converts this XML file to code and its just like normal python code.

                      you can also load UI files at runtime
                      https://doc.qt.io/qtforpython-5/PySide2/QtUiTools/QUiLoader.html
                      but then its a bit more clumsy to get to talk to them.

                      L Offline
                      L Offline
                      lfreeman6490
                      wrote on last edited by
                      #10

                      @mrjj Okay I'll look at that. Thank you very much. I appreciate the help :]

                      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