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. How does a PyQt Slot access a different class' object function? OO newbie confusion!

How does a PyQt Slot access a different class' object function? OO newbie confusion!

Scheduled Pinned Locked Moved Language Bindings
4 Posts 3 Posters 3.8k Views
  • 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.
  • S Offline
    S Offline
    snoop911
    wrote on last edited by
    #1

    So I have a window class ui file that has all the buttons and functions that take care of the display..

    My application's .py file loads/instantiates the window class, but it also does non-gui type stuff and therefore has non-gui related objects.

    What I'd like to do, for example is whenever a button is pressed, the non-gui object's function gets called.

    Architecturally or syntaxically (?) how is this typically performed? Should the windows class inherit from these non-window type classes? I'm sure I can make the objects functions into global functions, but doesn't that defeat the OO spirit?

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

      Hi,

      You can follow more or less the same rules that would apply in C++ here.

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

      1 Reply Last reply
      0
      • E Offline
        E Offline
        elveatles
        wrote on last edited by
        #3

        Here's an example in case that's what you were looking for. self.someButton is a QPushButton, and self.someObject is the object with the onClick method that will be called when the signal is emitted.

        @
        self.someButton.clicked.connect(self.someObject.onClick)
        @

        1 Reply Last reply
        0
        • S Offline
          S Offline
          snoop911
          wrote on last edited by
          #4

          Thanks! That's what I as looking for!

          [quote author="elveatles" date="1406940916"]Here's an example in case that's what you were looking for. self.someButton is a QPushButton, and self.someObject is the object with the onClick method that will be called when the signal is emitted.

          @
          self.someButton.clicked.connect(self.someObject.onClick)
          @[/quote]

          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