Packages found by Scott Stubbs

This helps automate moving from pyqt4 to pyqt5:  https://github.com/rferrazz/pyqt4topyqt5 and this old (unsupported?) software for C:  https://github.com/KDAB/Qt4to5

Notes from Hayden Blair on C++ migration of PSQt package:

 

1) Error came up on compilation; said that the output files needed to be position independent. 

  • Solved by including: "CCFLAGS='-fPIC -g -O0' " as an argument in the standardSConscript() function.
2) Qt4 to Qt5 transition dictates replacing <QtGui> with <QtWidgets>
  • Wrote a bash script to make this change in every single header file
3) Mikhail changed the "currentChanged()" function (which is a member function of the QItemSelectionModel class in Qt) to output a string that contained the name of the item being changed, when this function was called. This function was called on startup (when an instance of the "GeoTree" class was created) and did not have proper input parameters for this first call, which led to the creation of a nil pointer and a subsequent seg fault. I fixed this by adding an if statement that only allows "currentChanged()" to be utilized if the index in its argument is valid. I don't know why this fix wasn't necessary in the older version of the code. I have left a couple print commands in the if statement to draw attention to the fact that this problem merits more attention. 
4) In the file "allinone.cpp", in the function "MyWidget" I had to cast the last argument of every "addItem" statement as an integer. For each instance, the last argument was setting a "PenStyle" preference. Each specific selection (i.e. Qt::SolidLine, Qt::DashLine, Qt::DotLine, etc) was a private member of the PenStyle class, so the program was crashing when it tried to access the information. Casting each one of the selections as an int allowed addItem to select from an index of Pen Styles rather than trying to access the private data members specifically. 
5) In standardSConscipt.py: Changed all instances of "qt4" to "qt5" (regardless of case)
6) In qt5.py, on line 48: Changed names of pakcages to include a 5 in name.
  • ex: "QtCore" went to "Qt5Core". All other packages followed the same naming convention  

Notes from Ian Roque on python migration of python QT packages:

 

Porting to Qt5 in python is a bit easier than in c++

 

Naturally, all the PyQt4's are change to PyQt5. (i.e from PyQt5 import QtCore)

Similarly, matplotlib now uses Qt5Agg instead of Qt4Agg.

 

Some of Qt4's QtGui functionalities have migrated to QtWidgets so it is imported at the start of python files.

Because of this, we changed QtGui to QtWidgets throughout the code when necessary (i.e QtWidgets.QApplication.setOverrideCursor())

 

Wheel events (specifically in graphqt) have been changed for zooming in and out:

e is now called events

e.delta() is now event.angledelta.y() for scrolling. (This allows the computer to understand moving the mouse wheel up or down)

 

Most of the work consists of changing QtGui to QtWidgets wherever it is needed, but not in all places as QtGui still retains some functions separate from QtWidgets. This is best done by reading the documentation and using a script to do the work for you.


After adjusting Calibman following the previous guidelines, we were able to get the GUI to appear but it repeatedly crashed when using the Mask Editor.
To the best of our understanding, Calibman is currently refusing to use the Qt5 backend, even in a Qt5 environment. 
When we ran it, MatPlotLib would always default to the Qt4 backend even after specifically calling the Qt5Agg. 
This led us to a series of syntax errors and attribute errors in multiple files which impedes Calibman operations
as Qt4 code is not forward compatible with Qt5. 

From Clemens:  tricky part of embedding matplotlib in QT is using matplotlib.pyplot.  Ideally shouldn't use that API because it imports backends by itself, in particular QT4 backends (Qt4Agg).  Can override it by matplotlib.use('Qt5Agg') but have to do this before every matplotlib.pyplot.  calibman uses matplotlib for some plotting.


  • No labels