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.1k 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 3 Oct 2023, 13:31 last edited by NoRulez 10 Mar 2023, 13:32
    #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?

    J 1 Reply Last reply 3 Oct 2023, 14:36
    0
    • N NoRulez
      3 Oct 2023, 13:31

      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?

      J Offline
      J Offline
      JonB
      wrote on 3 Oct 2023, 14:36 last edited by JonB 10 Mar 2023, 14:36
      #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
      • S Offline
        S Offline
        SGaist
        Lifetime Qt Champion
        wrote on 3 Oct 2023, 19:15 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 4 Oct 2023, 06:31
        0
        • S SGaist
          3 Oct 2023, 19:15

          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 4 Oct 2023, 06:31 last edited by NoRulez 10 Apr 2023, 06:31
          #4

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

          J 1 Reply Last reply 4 Oct 2023, 08:30
          0
          • N NoRulez
            4 Oct 2023, 06:31

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

            J Offline
            J Offline
            JonB
            wrote on 4 Oct 2023, 08:30 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?

            S 1 Reply Last reply 4 Oct 2023, 11:32
            0
            • J JonB
              4 Oct 2023, 08:30

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

              S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 4 Oct 2023, 11:32 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

              J 1 Reply Last reply 4 Oct 2023, 13:15
              1
              • S SGaist
                4 Oct 2023, 11:32

                Hi,

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

                J Offline
                J Offline
                JonB
                wrote on 4 Oct 2023, 13:15 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

                1/7

                3 Oct 2023, 13:31

                • Login

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