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. Signal connect with different class
Forum Updated to NodeBB v4.3 + New Features

Signal connect with different class

Scheduled Pinned Locked Moved Language Bindings
8 Posts 3 Posters 6.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.
  • I Offline
    I Offline
    ictsecurity0
    wrote on last edited by
    #1

    hai,

    sorry i have a problem to paste the code here. my code http://pastebin.com/kL3Q6B3W

    my question is:
    @
    self.connect(self.lineedit, QtCore.SIGNAL("returnPressed()"), MyDisplay.updateUi())
    @
    can i send the signal (emitted by self.lineedit) to another class which is defined by MyDisplay.updateUi???

    or anyone have the example code please tell me

    thanks

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      Disclaimer: I am not familiar with PyQt (or much with Python at all, in fact).

      There is no problem at all connecting signals and slots between different classes, as long as those classes are both QObject derived. So in fact, you are connecting two QObjects always.

      1 Reply Last reply
      0
      • G Offline
        G Offline
        goetz
        wrote on last edited by
        #3

        [quote author="ictsecurity0" date="1313646336"]hai,
        @
        self.connect(self.lineedit, QtCore.SIGNAL("returnPressed()"), MyDisplay.updateUi())
        @
        [/quote]

        The syntax should be the same on PyQt as on C++:

        @
        self.connect(self.lineedit, QtCore.SIGNAL("returnPressed()"), MyDisplay, QtCore.SLOT("updateUi()"))
        @

        http://www.catb.org/~esr/faqs/smart-questions.html

        1 Reply Last reply
        0
        • I Offline
          I Offline
          ictsecurity0
          wrote on last edited by
          #4

          [quote author="Volker" date="1313663456"]
          [quote author="ictsecurity0" date="1313646336"]hai,
          @
          self.connect(self.lineedit, QtCore.SIGNAL("returnPressed()"), MyDisplay.updateUi())
          @
          [/quote]

          The syntax should be the same on PyQt as on C++:

          @
          self.connect(self.lineedit, QtCore.SIGNAL("returnPressed()"), MyDisplay, QtCore.SLOT("updateUi()"))
          @

          [/quote]

          still got the error. I tried alot of method to pass the signal of 'returnPassed()' to another class.

          the error"IdentationError:expected an indented block..

          My code is here http://pastebin.com/wBhWGxCX

          i just want to do some simple print feature but failed

          thanks

          1 Reply Last reply
          0
          • A Offline
            A Offline
            andre
            wrote on last edited by
            #5

            The code in your pastebin has mismatched parenthesis, I think.

            1 Reply Last reply
            0
            • G Offline
              G Offline
              goetz
              wrote on last edited by
              #6

              [quote author="ictsecurity0" date="1313735715"]
              still got the error. I tried alot of method to pass the signal of 'returnPassed()' to another class.

              the error"IdentationError:expected an indented block..

              [/quote]

              I'm by no means a Python export, but that error message looks quite unrelated to Qt... Did you mix up spaces and tabs?

              http://www.catb.org/~esr/faqs/smart-questions.html

              1 Reply Last reply
              0
              • I Offline
                I Offline
                ictsecurity0
                wrote on last edited by
                #7

                i solved the problem with using lambda:

                self.connect(lineedit, QtCore.SIGNAL('returnPressed()'), lambda: MyDisplay().updateUi())

                anyway, thanks :)

                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  andre
                  wrote on last edited by
                  #8

                  I think you could have solved it with just an additional closing parentheses ) after the connect statement in your original code...

                  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