Rapid Gui Programming – part 2

I just completed the excercise for chapter 7 in which you create a form using Qt Designer and give it the functionality to search and replace some text. As usual I had to port it from PyQt4 to PyQt5. The signals gave me a little problem as they frequently can. In this case it was necessary to declare two custom signals which were used as you can see below. The stumbling block for me was that I didn’t provide for the found signal to pass in integer parameter.

# In porting this from PyQt4 I had to create two signals that
# were created in-line in the original program like this:
#   form.connect(form, SIGNAL("found"), found)
#   form.connect(form, SIGNAL("notfound"), nomore)

# This syntax is no longer possible with PyQt5 and the new style
# signals. The signal must be declared as a class atribute and as
# such must be declared as the first item in the class before any
# method definition. The notfound signal doesn't take an argument so 
# none is given in the declaration. found returns the index of where
# the text was found so it takes an integer argument which must be
# declared like so: found = pyqtSignal(int) vs notfound = pyqtSignal()

                 This is the form that is created

2016-04-08 (3)

Author: korkiley

Systems Administrator at University of Vermont (retired as of 7/1/2012) Married Favorite Activities: Condor Glider Online Competition, Developing web sites, making espresso, and keeping a blog

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: