Qt4/Qt5 neutral compilation fixes

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

Re: Qt4/Qt5 neutral compilation fixes

Postby wmayer » Tue Dec 27, 2016 4:10 pm

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
Site Admin
Posts: 15471
Joined: Thu Feb 19, 2009 10:32 am

Re: Qt4/Qt5 neutral compilation fixes

Postby wmayer » Wed Dec 28, 2016 9:13 am

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
Posts: 3175
Joined: Mon Nov 11, 2013 5:29 pm

Re: Qt4/Qt5 neutral compilation fixes

Postby looo » Wed Dec 28, 2016 11:33 am

nice to see this is working.
please help with my conda-packaging efforts: https://liberapay.com/looooo/
minimalistic blog: https://looooo.github.io/mini-blog/
triplus
Posts: 9278
Joined: Mon Dec 12, 2011 4:45 pm

Re: Qt4/Qt5 neutral compilation fixes

Postby triplus » Wed Dec 28, 2016 12:05 pm

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
Posts: 3175
Joined: Mon Nov 11, 2013 5:29 pm

Re: Qt4/Qt5 neutral compilation fixes

Postby looo » Wed Dec 28, 2016 1:08 pm

regarding ui files:

we are building them, so the right pyside version should be used there.
please help with my conda-packaging efforts: https://liberapay.com/looooo/
minimalistic blog: https://looooo.github.io/mini-blog/
User avatar
Kunda1
Posts: 7028
Joined: Thu Jan 05, 2017 9:03 pm

Re: Qt4/Qt5 neutral compilation fixes

Postby Kunda1 » Mon Mar 27, 2017 5:59 pm

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
Want to contribute back to FC? Checkout:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features