Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8342083
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T05:40:09+00:00 2026-06-09T05:40:09+00:00

I am having difficulty connecting a signal with a method in PyQt4. I can

  • 0

I am having difficulty connecting a signal with a method in PyQt4.
I can connect a bound signal of object A with a method of object B,
but I can’t connect a bound signal of object A with a method of self
(object where the connections are made.)
What am I doing wrong? See below:

from PyQt4.QtGui import *
from PyQt4.QtCore import *


class FooA(QObject):
    trigger=pyqtSignal(str)

    def receive_trigger(self,a):
        print'triggered in FooA, string',a

class MainObj(QObject):
    def __init__(self):
        self.a1=FooA()
        self.a2=FooA()
        #I can connect signals and methods of separate objects:
        self.a1.trigger.connect(self.a2.receive_trigger)
        self.a1.trigger.emit('hi')
        #... but I can't connect a signal with a method of self
        self.a1.trigger.connect(self.receive_trigger)
        self.a1.trigger.emit('hi')
    def receive_trigger(self,a):
        print 'triggered in MainObj'

executes as:
MainObj()

triggered in FooA, string hi
triggered in FooA, string hi

I expected to see an additional line, > triggered in MainObj

Thanks in advance.
Bill

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T05:40:11+00:00Added an answer on June 9, 2026 at 5:40 am

    As you already seem to know, signals must belong to QObjects, but this problem is occurring because you are not calling the constructor of QObject. FooA does not override the constructor, therefore the default constructor is called and the signals work as expected. In MainObj however, you do not call the superclass’ (QObject) constructor, so signals will not work. To fix, either put:

    QObject.__init__(self)
    

    or

    super(QObject, self).__init__()
    

    (based on your conventions) at the top of MainObjs contructor, and the signals will then work as expected.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having difficulty connecting my java code to sql server database. I can
I am having difficulty with getting this work. I can connect to the database
I have adjusted my code slightly but I am still having difficulty posting it
I'm having difficulty converting some NSOperation code to ARC. My operation object uses a
I am having difficulty deciding which is the best method for saving my app
I've done this before but for some reason I'm really having some difficulty creating
I'm having difficulty getting python 2.4 to connect to gmail's smtp server. My below
I am having difficulty in my Qt program with connecting button signals to my
I am having some difficulty converting this list of strings into a list of
Having difficulty indexing an attachment type in elasticsearch via the Tire gem. Not able

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.