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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T08:31:16+00:00 2026-05-11T08:31:16+00:00

I am starting to learn Qt4 and Python, following along some tutorial i found

  • 0

I am starting to learn Qt4 and Python, following along some tutorial i found on the interwebs. I have the following two files:

lcdrange.py:

from PyQt4 import QtGui, QtCore  class LCDRange(QtGui.QWidget):                             def __init__(self, parent=None):         QtGui.QWidget.__init__(self, parent)          lcd = QtGui.QLCDNumber(2)          self.slider = QtGui.QSlider()         self.slider.setRange(0,99)         self.slider.setValue(0)          self.connect(self.slider, QtCore.SIGNAL('valueChanged(int)'),                      lcd, QtCore.SLOT('display(int)'))         self.connect(self.slider, QtCore.SIGNAL('valueChanged(int)'),                      self, QtCore.SIGNAL('valueChanged(int)'))          layout = QtGui.QVBoxLayout()         layout.addWidget(lcd)         layout.addWidget(self.slider)         self.setLayout(layout)      def value(self):         self.slider.value()      def setValue(self,value):         self.slider.setValue(value) 

main.py:

import sys from PyQt4 import QtGui, QtCore  from lcdrange import LCDRange  class MyWidget(QtGui.QWidget):     def __init__(self, parent=None):         QtGui.QWidget.__init__(self, parent)          quit = QtGui.QPushButton('Quit')         quit.setFont(QtGui.QFont('Times', 18, QtGui.QFont.Bold))         self.connect(quit, QtCore.SIGNAL('clicked()'), QtGui.qApp, QtCore.SLOT('quit()'))          grid = QtGui.QGridLayout()         previousRange = None          for row in range(0,3):             for column in range(0,3):                 lcdRange = LCDRange()                  grid.addWidget(lcdRange, row, column)                 if not previousRange == None:                     self.connect(lcdRange, QtCore.SIGNAL('valueChanged(int)'),                                  previousRange, QtCore.SLOT('setValue(int)'))                 previousRange = lcdRange          layout = QtGui.QVBoxLayout()         layout.addWidget(quit)         layout.addLayout(grid)         self.setLayout(layout)     app = QtGui.QApplication(sys.argv)  widget = MyWidget() widget.show()   sys.exit(app.exec_()) 

When i run this i get the following errors:

Object::connect: No such slot LCDRange::setValue(int) Object::connect: No such slot LCDRange::setValue(int) Object::connect: No such slot LCDRange::setValue(int) Object::connect: No such slot LCDRange::setValue(int) Object::connect: No such slot LCDRange::setValue(int) Object::connect: No such slot LCDRange::setValue(int) Object::connect: No such slot LCDRange::setValue(int) Object::connect: No such slot LCDRange::setValue(int) 

I’ve read that PyQt slots are nothing more than methods, which i have defined, so what am i doing wrong?

I am also learning Qt4 with Ruby which is where this code originates from, i translated it from Ruby to Python. In the Ruby version the LCDRange class is defined as this:

class LCDRange < Qt::Widget   signals 'valueChanged(int)'   slots 'setValue(int)'    def initialize(parent = nil)   ... 

So my guess was that i have to somehow declare the existence of the custom slot?

  • 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. 2026-05-11T08:31:16+00:00Added an answer on May 11, 2026 at 8:31 am

    Try this:

    self.connect(lcdRange, QtCore.SIGNAL('valueChanged'), previousRange.setValue) 

    What’s the difference?

    The PyQt documentation has a section about SIGNALS/SLOTS in PyQt, they work a little differently.

    SIGNAL

    SIGNAL('valueChanged') is something called a short-circuit signal. They work only for Python-to-Python methods, but they are faster and easier to implement.

    SLOT

    If you have a python slot, you can specify it just by tipping the method: previousRange.setValue. This works for all methods accessible by Python.

    If your slots should be accessible like C++ Qt slots, as you tried in your code, you have to use a special syntax. You can find information about pyqtSignature decorator on the PyQt website.

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

Sidebar

Ask A Question

Stats

  • Questions 210k
  • Answers 210k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer oh, how comes - i've solved this problem: public sealed… May 12, 2026 at 10:03 pm
  • Editorial Team
    Editorial Team added an answer You can't have arrays of size 0, so 1 is… May 12, 2026 at 10:03 pm
  • Editorial Team
    Editorial Team added an answer The .NET FCL doesn't provide a class like java.util.zip.CRC32 so… May 12, 2026 at 10:03 pm

Related Questions

I am starting to learn the Clojure programming language. Are there any recommendations for
I am starting to learn ASP.NET MVC. I have deployed the stock ASP.NET MVC
I am starting to learn reverse engineering and wanted to know what tools people
I am starting to learn Silverlight game programming, and was wondering if anyone knows

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.