Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Supporting Qt6 / PySide6 / Shiboken6 #6992

Open
19 tasks
luzpaz opened this issue Jan 27, 2022 · 24 comments
Open
19 tasks

Supporting Qt6 / PySide6 / Shiboken6 #6992

luzpaz opened this issue Jan 27, 2022 · 24 comments
Labels
3rd party: Qt 6 Issue related to Qt 6 Feature FR for improvements or new features Packaging: AppImage AppImage related Packaging/building Related to building, compiling or packaging FreeCAD Packaging: Conda Conda packaging related Packaging: flatpak flatpak related Packaging: Snap Snap packaging related

Comments

@luzpaz
Copy link
Contributor

luzpaz commented Jan 27, 2022

This ticket tracks the Qt5 ➡️ Qt6 migration progress. See also dedicated forum thread

Commits

Qt6 commits to master:

commit summary committer
339bb73 Base: add convenience classes/functions that are marked as deprecated in Qt 5.15 and removed in Qt 6 wwmayer

Notes

Source code tasks

Module level changes

  • The content of the QtOpenGL module has been replaced. The class QGLWidget and related classes (QGLContext, QGLFunctions, QGLShaderProgram) have been removed. Parts of the Open GL functionality from QtGui have been extracted into this module, for example QOpenGLBuffer and QOpenGLShaderProgram. There is a new module QtOpenGLWidgets which contains the class QOpenGLWidget, a replacement for QGLWidget.

Imports

  • Change PySide2 -> PySide6
    Ex.
     from PySide2.QtWidgets import QApplication...
     from PySide2 import QtCore
    to
     from PySide6.QtWidgets import QApplication...
     from PySide6 import QtCore
  • Some classes are in a different module now, for example QAction and QShortcut have been moved from QtWidgets to QtGui.

Class/Function Deprecations

  • The High DPI scaling attributes Qt.AA_EnableHighDpiScaling, Qt.AA_DisableHighDpiScaling and Qt.AA_UseHighDpiPixmaps are deprecated. High DPI is by default enabled in Qt 6 and cannot be turned off.
  • QDesktopWidget has been removed. QScreen should be used instead, which can be retrieved using QWidget.screen(), QGuiApplication.primaryScreen() or QGuiApplication.screens().
  • QFontMetrics.width() has been renamed to horizontalAdvance().
  • QMouseEvent.pos() and QMouseEvent.globalPos() returning a QPoint as well as QMouseEvent.x() and QMouseEvent.y() returning int are now deprecated. QMouseEvent.position() and QMouseEvent.globalPosition() returning a QPointF should be used instead.
  • Qt.MidButton has been renamed to Qt.MiddleButton.
  • QOpenGLVersionFunctionsFactory.get() instead of QOpenGLContext.versionFunctions() should be used to obtain Open GL functions.
  • QRegExp has been replaced by QRegularExpression.
  • QWidget.mapToGlobal() and QWidget.mapFromGlobal() now also accept and return QPointF.
  • Functions named exec_ (classes QCoreApplication, QDialog, QEventLoop) have been renamed to exec which became possible in Python 3.

Other tasks

@luzpaz
Copy link
Contributor Author

luzpaz commented Jan 27, 2022

@hobbes1069
Copy link
Contributor

This would be great as Qt isn't updating pyside for Qt 5 to be compatible with Python 3.10/3.11.

@ipatch
Copy link
Contributor

ipatch commented Jan 27, 2022

@hobbes1069

have you taken a look at this?

FreeCAD/homebrew-freecad#267

and more specifically this,

FreeCAD/homebrew-freecad#267 (comment)

so drilling into the bug report i filed with the upstream pyside project,

https://bugreports.qt.io/browse/PYSIDE-1763

it seems certain patches could be back ported for pyside 5.15.2 to work with python ≥ 3.10

however this approach seems it will only get more brittle as dependencies move forward ie. python.


@luzpaz

i agree there should be some effort applied to begin supporting qt6 as opposed to applying patches.

in another note, i know python 3.10 is released now, but does freecad use any language feature added in python 3.10 that would make it more beneficial to use python 3.10 over python 3.9. or are we just updating for the sake of updating?

finally, i think this github issue should be placed in the freecad src repo, ie. https://github.com/freecad/freecad (or are we placing here because the upstream repo does not have github issues enabled on the project and is using its own bug tracker?) Several cmake files will require updating to support qt6 at the least, and not tomention all the header import statements that import/use qt libs that have probably been renamed since qt5. it will definitely require some effort.

@hfiguiere
Copy link

The problem with Python 3.10 is that it will be on most Linux distro and in the next Flatpak runtime (August 2022). So it will definitely be a problem.

@hobbes1069
Copy link
Contributor

hobbes1069 commented Jan 28, 2022

Exactly. Fedora 35 already has Python 3.10 and Fedora 36 (current rawhide) will have 3.11.

TBH, I'm pretty fatigued at trying to keep FreeCAD running in Fedora. Maybe appimage/flatpak should be the primary distribution method on Linux.

@waebbl
Copy link
Contributor

waebbl commented Jan 29, 2022

On Gentoo we have Python 3.10 and 3.11_alpha available. It's planned to make 3.10 the default Python interpreter in July. Qt6 is packaged, but still masked, and AFAICS there's not much pressure to change this.

It seems like the Qt folks are preparing a special PySide version with Python 3.10 compatibility: 5.15.2.1 to be release soon, special version with Python 3.10 support.

@donovaly
Copy link
Member

The problem with Python 3.10 is that it will be on most Linux distro and in the next Flatpak runtime (August 2022). So it will definitely be a problem.

Why is this a problem? What code that runs with Python 3.8 cannot be executed in Python 3.10?
Also, what Qt 5.15.2 compatible code won't be executable with Qt 6?

I find it important to know precisely what code is affected and what not.

@luzpaz
Copy link
Contributor Author

luzpaz commented Jan 29, 2022

It's discussed in the forum thread: https://forum.freecadweb.org/viewtopic.php?f=10&t=65089
Issues with coin3d/pivy and pyside

@donovaly
Copy link
Member

It's discussed in the forum thread: https://forum.freecadweb.org/viewtopic.php?f=10&t=65089 Issues with coin3d/pivy and pyside

I cannot find anything when searching for "coin3d" in this thread. Can you therefore please list the affected code here in a short list to keep the overview?

@hobbes1069
Copy link
Contributor

Hopefully a new PySide release @waebbl mentioned get's released soon, but to answer part of your question:
https://bugzilla.redhat.com/show_bug.cgi?id=1990768
https://bugzilla.redhat.com/show_bug.cgi?id=2025599

@luzpaz luzpaz transferred this issue from FreeCAD/FreeCAD-Bundle Jun 8, 2022
@luzpaz
Copy link
Contributor Author

luzpaz commented Jun 8, 2022

Transferred to FreeCAD/FreeCAD repo

@luzpaz luzpaz added Packaging/building Related to building, compiling or packaging FreeCAD Packaging: AppImage AppImage related Packaging: Conda Conda packaging related Packaging: Snap Snap packaging related Packaging: flatpak flatpak related labels Jun 8, 2022
@luzpaz luzpaz changed the title Supporting Qt6 Supporting Qt6/PySide6/Shiboken6 Jun 25, 2022
@luzpaz luzpaz changed the title Supporting Qt6/PySide6/Shiboken6 Supporting Qt6 / PySide6 / Shiboken6 Jun 25, 2022
@luzpaz
Copy link
Contributor Author

luzpaz commented Jun 25, 2022

Added the Porting from PySide2 to PySide6 link to the OP of this ticket.

@luzpaz
Copy link
Contributor Author

luzpaz commented Jul 14, 2022

Started tracking Qt6 commits to master in the OP. See Commits section

@luzpaz
Copy link
Contributor Author

luzpaz commented Jul 16, 2022

Hi @wwmayer, how would you feel about linking Qt6 related commits to this ticket so we can track them in one place?

@wwmayer
Copy link
Contributor

wwmayer commented Jul 16, 2022

339bb73 is not directly related to Qt6 but allows to reduce some if QT_VERSION < QT_VERSION_CHECK(...) checks in client code.

@luzpaz
Copy link
Contributor Author

luzpaz commented Nov 8, 2022

Related:
#7712
#7677
#7647

@iamdbychkov
Copy link

iamdbychkov commented Nov 17, 2022

*** There was a question on how to use FreeCad on newer linux distributions.

My answer was to use appimage from official website instead of installing freecad from OS repos.

@luzpaz luzpaz added the 3rd party: Qt 6 Issue related to Qt 6 label Apr 16, 2023
@adrianinsaval
Copy link
Member

what's still missing for qt6 support?

@berniev
Copy link
Contributor

berniev commented May 31, 2023

MacAppBundle/CMakeLists.txt
Resolve Homebrew v Pip v native on macOS esp re Python, PySide, Shiboken

@luzpaz
Copy link
Contributor Author

luzpaz commented Jul 23, 2023

Added #9977 to the OP

@luzpaz
Copy link
Contributor Author

luzpaz commented Aug 6, 2023

We're gonna need some help porting Snap to Qt6 (FreeCAD/FreeCAD-snap#19). Volunteers for this would be very much appreciated!

@chennes
Copy link
Member

chennes commented Oct 23, 2023

FYI compiling against Qt6 with MSVC activates the /permissive- option, which we don't currently support. PR #11014 will address these issues.

@luzpaz
Copy link
Contributor Author

luzpaz commented Dec 24, 2023

a nightly F(edora)39 build at this point isn't going to happen against the stock F39 repos, as there are no python qt5 bindings. For a FreeCAD nightly to be compiled successfully for F39, python qt6 bindings need to be in the virtual environment (there is already a build in copr for python-pyside6). This would require copr to include python-pyside6 in it's virtual build environment for FreeCAD nightly (it can be done, but I don't have enough experience with copr to set it up properly). When (and if) FreeCAD nightly is compiled successfully, any user who enables the FreeCAD nightly repo and wants to use it, would need to install python-pyside6 too - either will be provided from another copr repo, or ideally shipped in the FreeCAD copr repo (until Fedora officially includes the python-pyside6 in their official repos). Can someone just fix the references in the spec file from master to main, so we can get at least an attempt for a build for F38. It might finish successfully, or it might fail, but at least we can get the logs.

ref: #11619 (comment)

@adrianinsaval
Copy link
Member

Are they using Py_LIMITED_API in their pyside build? Pyside6 uses it by default I think, I had to disable it to be able to build freecad on flatpak because freecad doesn't support that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3rd party: Qt 6 Issue related to Qt 6 Feature FR for improvements or new features Packaging: AppImage AppImage related Packaging/building Related to building, compiling or packaging FreeCAD Packaging: Conda Conda packaging related Packaging: flatpak flatpak related Packaging: Snap Snap packaging related
Projects
None yet
Development

No branches or pull requests