Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. Connecting signals from C++ application with Python?
Forum Updated to NodeBB v4.3 + New Features

Connecting signals from C++ application with Python?

Scheduled Pinned Locked Moved Unsolved Qt for Python
7 Posts 3 Posters 1.0k 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.
  • N Offline
    N Offline
    NoRulez
    wrote on last edited by NoRulez
    #1

    Hi everyone,

    I have a C++ application which loads the *.ui files dynamically with the QUiLoader.
    For this example MyWidget.ui

    Now I want to add the connections for QDial and a QLabel in the Python file (MyWidget.py).

    What works in C++ currently is to get the QWidget* from the QUiLoader and access the items with findChildren<QLabel*>().

    Can someone please help?

    JonBJ 1 Reply Last reply
    0
    • N NoRulez

      Hi everyone,

      I have a C++ application which loads the *.ui files dynamically with the QUiLoader.
      For this example MyWidget.ui

      Now I want to add the connections for QDial and a QLabel in the Python file (MyWidget.py).

      What works in C++ currently is to get the QWidget* from the QUiLoader and access the items with findChildren<QLabel*>().

      Can someone please help?

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

      @NoRulez
      Why aren't you using Qt + Python + PySide/PyQt for everything? I don't think it will be easy to connect across languages.

      You can try the findChildren() approach for Python, if that does whatever you want.

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

        Hi,

        What exactly are you trying to do ?
        Port your C++ code to Python ?
        Use your C++ code in a Python application ?

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

        N 1 Reply Last reply
        0
        • SGaistS SGaist

          Hi,

          What exactly are you trying to do ?
          Port your C++ code to Python ?
          Use your C++ code in a Python application ?

          N Offline
          N Offline
          NoRulez
          wrote on last edited by NoRulez
          #4

          @SGaist The main application is written in C++ and I want to extend it with python scripting

          JonBJ 1 Reply Last reply
          0
          • N NoRulez

            @SGaist The main application is written in C++ and I want to extend it with python scripting

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

            @NoRulez
            Here is my $0.02, unless/until someone else knows better.

            To add "Python scripting" to a C++ program you are best searching for C++ to Python scripting, not to do with Qt. That will be possible.

            However, you (apparently) want to be able to handle Qt stuff like signals/slots from your Python "scripting". In order to call and deal with Qt stuff from Python you (normally) need a set of Python bindings/library, as provided by either PySide or PyQt. But these (again, normally) provide and require a full program written with them. I don't know how/whether they would allow you have Qt (with its event loop etc.) in a C++ program and somehow "connect" to that.

            If that cannot be done could your "scripting" be done without any reference to anything Qt?

            SGaistS 1 Reply Last reply
            0
            • JonBJ JonB

              @NoRulez
              Here is my $0.02, unless/until someone else knows better.

              To add "Python scripting" to a C++ program you are best searching for C++ to Python scripting, not to do with Qt. That will be possible.

              However, you (apparently) want to be able to handle Qt stuff like signals/slots from your Python "scripting". In order to call and deal with Qt stuff from Python you (normally) need a set of Python bindings/library, as provided by either PySide or PyQt. But these (again, normally) provide and require a full program written with them. I don't know how/whether they would allow you have Qt (with its event loop etc.) in a C++ program and somehow "connect" to that.

              If that cannot be done could your "scripting" be done without any reference to anything Qt?

              SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Hi,

              You might want to check the Scriptable Application example as a starting point.

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

              JonBJ 1 Reply Last reply
              1
              • SGaistS SGaist

                Hi,

                You might want to check the Scriptable Application example as a starting point.

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

                @SGaist
                Interesting, didn't know about that page. Not sure how complex it is. I wonder how it will cope with, say, signals connected to multiple slots written in different languages.

                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