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

  • Home
  • SEARCH
  • 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 8143645
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T13:10:23+00:00 2026-06-06T13:10:23+00:00

In a PyQt4 app I connect a slider to one or another slot depending

  • 0

In a PyQt4 app I connect a slider to one or another slot depending on user actions. I change the slot assignment in response to button clicks. The several different slots do different things, too different to merge into one slot with some “if” statements.

This app crashes frequently. I am wondering if it’s kosher to be reassigning slots to one signal on the fly like this. Could this lead to dangling pointers internal to PyQt4, memory corruption, or something else bad? If what I’m doing is okay, I will look elsewhere for the bug.

Here’s a very sketch version of my app:

def MyThing(QWidget):

    (in some approprate place)
       self.s = QSlider()


    def MethodOne(self):   # this is a slot handling a button click
       self.s.valueChanged.connect(self.someslot1)

    def MethodTwo(self):   # likewise
       self.s.valueChanged.connect(self.someslot2)

    def someslot1(self, svalue):  # slider movement handler
       (compute, show info based on slider position)

    def someslot2(self, svalue):   # similar to someslot1
       ....
  • 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-06T13:10:26+00:00Added an answer on June 6, 2026 at 1:10 pm

    If the 2 connected objects still exist when you call connect, that shouldn’t cause a crash by itself.

    According to your code, you don’t seem to disconnect the previously connected slots (with self.s.valueChanged.disconnect() for instance), and that can cause both slots to be called multiple times for each signal, which means that your application could slow down with time, and might crash depending on what you do in the slots.

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

Sidebar

Related Questions

I have a fairly simple app built with pyqt4. I wanted to debug one
I tried to run a PyQt4 app, but got following error: cannot connect to
I'm creating a User Interface using PyQt4 module . the problem i'am facing is
I'm working a small qt app (using PyQt4) and I've come up with an
I'm writing a cross platform app in PyQt4. For a particular feature, I would
I'm trying to write some kind of API client for PyQt4-based app. And, following
We have a PyQt4/PySide Qt4 video player app that has QToolButton object in the
I want to create an app, where the user will decide it the main
Well, I'm writing a small PyQt4 app, it's just a single Yes/No dialog which
How can i make my qmenu checkable? from PyQt4 import QtGui app = QtGui.QApplication([])

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.