Qt4/Qt5 neutral compilation fixes

Merged, abandoned or rejected pull requests are moved here to clear the main Pull Requests forum.
wmayer
Founder
Posts: 20243
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Qt4/Qt5 neutral compilation fixes

Post by wmayer »

Nice idea. I have created a directory PySide with an empty __init__.py file and a QtCore.py, QtGui.py and for now a QtSvg.py. The contents of these files are:
QtCore.py:

Code: Select all

from PySide2.QtCore import *

QCoreApplication.CodecForTr=0
QCoreApplication.UnicodeUTF8=1
QtGui.py:

Code: Select all

from PySide2.QtGui import *
from PySide2.QtWidgets import *
QtSvg.py:

Code: Select all

from PySide2.QtSvg import *
This way all the PySide code works fine so far with PySide2. Only the above CodecForTr and UnicodeUTF8 must be removed from the Python code since they don't exist in Qt5 any more.
wmayer
Founder
Posts: 20243
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Qt4/Qt5 neutral compilation fixes

Post by wmayer »

With git commit 23b0793a68 none of the Python modules need to be touched. So, I consider the Qt5/PySide2 migration as accomplished.
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: Qt4/Qt5 neutral compilation fixes

Post by looo »

nice to see this is working.
triplus
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: Qt4/Qt5 neutral compilation fixes

Post by triplus »

And how does the import statement look like now? Continue to use the same as in PySide? Reading the documentation from Qt.py two things are documented i noticed that could have some relevance (PySide/PySide2):

https://github.com/mottosso/Qt.py
setResizeMode was renamed setSectionResizeMode in Qt 5.
I use QTableWidget (the same applies for widgets like QTreeWidget) in one of my FreeCAD related modules and have set the resize mode for header. This i guess i will have to tackle myself in the future. Not a big problem but some heads up as likely sooner or later this issue will emerge in one of the default FreeCAD modules.

https://github.com/mottosso/Qt.py/blob/ ... CAVEATS.md

This note is interesting:
Compile Qt Designer files

.ui files compiled via pyside2-uic inherently contain traces of PySide2 - e.g. the line from PySide2 import QtGui.

In order to use these with Qt.py, or any other binding, one must first erase such traces and replace them with cross-compatible code.
Does the same apply for us?
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: Qt4/Qt5 neutral compilation fixes

Post by looo »

regarding ui files:

we are building them, so the right pyside version should be used there.
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: Qt4/Qt5 neutral compilation fixes

Post by Kunda1 »

BTW, any commits that are related to porting from Qt4 to Qt5 please link them to issue #2986
In the commit message you can write

Code: Select all

issue #2968
in order to auto-link it in MantisBT. See https://freecadweb.org/wiki/tracker#Att ... o_a_ticket
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
Post Reply