Rapid Gui Programming – Movies – Chapter 8

As I have mentioned here before, it is tricky for me to upgrade the scripts written by the author in PyQt4 to PyQt5, the version I am using (PyQt 5.5.1)

I’ve come up with new problems with chapter 8. The first was what I thought was another problem with signals.

I’ve snipped the segment of code with the original being commented (preceded with and *), and my solution below it.

original: self.connect(self.table, SIGNAL(“itemDoubleClicked(QTableWidgetItem*)”), self.editEdit)
QShortcut(QKeySequence(“Return”), self.table, self.editEdit)

In this case I spent a week or two trying to resolve this error:

File “C:/Users/kor/PycharmProjects/movies/mymovies.py”, line 79, in init
TypeError: argument 1 has unexpected type ‘NoneType’

Process finished with exit code 1

I thought it was a problem with the signal itemDoubleClicked. The Qt documentation for this is a bit weird and I tried many permutations of the itemDoubleClicked like itemDoubleClicked[QTableWidgetItem]. It turned out that there was no problem with the signal but with the slot which is the part in parenthesis at the end of the line (self.editEdit()). I made a classic beginner’s mistake. There should be no empty parentheses at the end. This always causes some kind of a problem. Usually when you take the action which is a double mouse click here, the program will crash. In this case I just couldn’t run it. so the line should have been:



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 )

Facebook photo

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

Connecting to %s

%d bloggers like this: