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 7965563
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T06:11:47+00:00 2026-06-04T06:11:47+00:00

I am trying to learn PyQt from rapid gui programming with python and qt

  • 0

I am trying to learn PyQt from rapid gui programming with python and qt and currently learning Signals and Slots.

Below is a short snippet of my code:

self.connect(self.dial, SIGNAL("valueChanged(int)"),self.spinbox.setValue) #1
self.connect(self.dial, SIGNAL("valueChanged(int)"),self.getValue_dial)    #2
self.connect(self.spinbox, SIGNAL("valueChanged(int)"),self.dial.setValue)
self.connect(self.spinbox, SIGNAL("valueChanged(int)"),self.getValue_spinbox)

def getValue_dial(self):
        print self.dial.value()

def getValue_spinbox(self):
        print self.dial.value()

What I am trying to achieve here is call 2 SLOTS at once that is spinbox.setValue and getValue_dial for dial object as soon as ValueChanged(int) signal is emitted.

The above code executes successfully without any errors and print the appropriate values as they are changed.

Now my question is the above way appropriate to call multiple slots for a single signal.?

Can the above two statements(1 & 2) be combined into a single statement.

Here is the link for my complete code.

  • 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-04T06:11:48+00:00Added an answer on June 4, 2026 at 6:11 am

    The way you’re doing it is fine. If you had quite a few things to do you could connect to a new function that handles everything for you.

    I notice in your connected getValue functions you’re getting the value straight from the object; are you aware that the value is passed as a parameter with the valueChanged(int) signal? If you change your getValue functions to accept an additional parameter there will be no need to get the value directly from the object. Of course you could do away with the getValue function all together and issue your print statement in the helper function.

    self.connect(self.dial, SIGNAL("valueChanged(int)"), self.dial_value_changed)
    self.connect(self.spinbox, SIGNAL("valueChanged(int)"),self.spinbox_value_changed)
    
    def dial_value_changed(self, value):
        self.spinbox.setValue(value)
        self.getValue_dial(value)
    
    def spinbox_value_changed(self, value):
        self.dial.setValue(value)
        self.getValue_spinbox(value)
    
    def getValue_dial(self, value):
            print value
    
    def getValue_spinbox(self, value):
            print value
    

    Also, and this is down to preference, there is a new style for signals and slots which can make the code a little easier to read. It would change the

    self.connect(self.dial, SIGNAL("valueChanged(int)"), self.dial_value_changed)
    self.connect(self.spinbox, SIGNAL("valueChanged(int)"),self.spinbox_value_changed)
    

    lines above to

    self.dial.valueChanged.connect(self.dial_value_changed)
    self.spinbox.valueChanged.connect(self.spinbox_value_changed)
    

    But for the original question and for the two things you’re doing I’d just connect the signal twice rather than have a helper function.

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

Sidebar

Related Questions

I´m trying to learn C#, coming from a Python/PHP background, and I´m trying to
Im trying to learn javascript and, having some basic programming experience already (from C++),
I've been trying to learn about metaclasses in Python. I get the main idea,
I'm trying to learn python and I'm attempting a hangman game. But when I
Trying to learn PL/SQL with multimedia data. Can anyone please point out that from
In trying to learn JavaScript closures, I've confused myself a bit. From what I've
Trying to learn jquery here so I took a regular javascript snippet that loops
Im trying to learn how to use JSON from within codeigniter. I'm trying to
Trying to learn ASP MVC coming from Linux/LAMP background (in other words I'm a
Trying to learn Regex in Python to find words that have consecutive vowel-consonant or

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.