View Single Post
Old 07-07-2014, 06:08 PM   #8
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 27,552
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Thanks for the advance notice, and the porting tips! Things have gone pretty smoothly for the little bit I've tried.

I did run into a bit of a snag with QListWidget in the move from PyQt4 to PyQt5. It might not affect too many, but I thought I'd share just in case.

I'm iterating the items of a QListWidget that allows multiple selections (to get a list of the indices of the items than are selected) and have found that the QListWidget.isItemSelected(QListWidgetItem * item) method no longer exists in PyQt5.

So the method I was using (that works in PyQt4):
Code:
book_indices = []
for index in xrange(qlist_widget.count()):
  qlist_widget_item = qlist_widget.item(index)
  if qlist_widget.isItemSelected(qlist_widget_item):
    book_indices.append(index)
Bombs in PyQt5.

The method that will work in both is:
Code:
book_indices = []
for index in xrange(qlist_widget.count()):
  qlist_widget_item = qlist_widget.item(index)
  if qlist_widget_item.isSelected():
    book_indices.append(index)
Which now that I see it, probably would have made more sense to begin with!

Anyway ... if anyone runs into issues with QListWidget while porting, keep in mind that the isItemSelected method has gone away in Qt5.
DiapDealer is offline   Reply With Quote