Supporting Qt 6 - What's needed?

As said above when running CMake you have to add the key Qt6Core_MOC_EXECUTABLE and set its value to /usr/lib/qt6/moc

I have created a branch that fixes all compiler warnings: https://github.com/wwmayer/FreeCAD/tree/Port_Qt6

Now it must be double-checked that the modifications do not change the behaviour.

Sorry i missed that, but my point is, there was another 13 references to /usr/lib/qt6/moc correctly detected even without setting
Qt6Core_MOC_EXECUTABLE

Only this two references to graphviz was missed.

cMake must know the path to this, since it uses it internally to do the AUTOMOC stuff, right? Any idea how to get access to it? I can see how to override it, using AUTOMOC_EXECUTABLE, but the docs make it sound like that variable is usually empty.

cMake must know the path to this, since it uses it internally to do the AUTOMOC stuff, right? Any idea how to get access to it? I can see how to override it, using AUTOMOC_EXECUTABLE, but the docs make it sound like that variable is usually empty.

I haven’t figured it out yet. In one .cmake file it uses a lot “Qt6::moc”, so maybe that could be used.

Oh, maybe the same way we find uic and rcc?

get_property(PYSIDE2_UIC_EXECUTABLE TARGET Qt::uic PROPERTY LOCATION)

so…

get_property(Qt6Core_MOC_EXECUTABLE TARGET Qt::moc PROPERTY LOCATION)

ETA: Yes, that works on my system, anyway. Maybe we don’t even need a version flag, just replace

set(QtCore_MOC_EXECUTABLE ${Qt${FREECAD_QT_MAJOR_VERSION}Core_MOC_EXECUTABLE})

with

get_property(QtCore_MOC_EXECUTABLE TARGET Qt::moc PROPERTY LOCATION)

Doing it this way worked for me: 9efb942e12df9ab

That’s because this case is handled separately from the other files, see https://github.com/FreeCAD/FreeCAD/blob/master/src/Gui/CMakeLists.txt#L284-L294. All the other calls are handled by CMake automoc, i.e. automatically by CMake.

Just found this thread. Can someone summarize or point me to a document on how to build FreeCAD with QT6? Currently because of upstreams refusal to update PySide2 to Python 3.12 we are about to retire FreeCAD from Fedora out of necessity.

Can someone summarize or point me to a document on how to build FreeCAD with QT6?

All what needs to be done is to run cmake as:

cmake -DFREECAD_QT_VERSION=6

For the build FreeCAD requires shiboken6 and PySide6 packages. And it’s not yet tested if FreeCAD works with Py3.12.

Do we still need to hand-compile coin and pivy so they are linked against Qt6 instead of Qt5?

ETA: Looks like yes to pivy, no to coin?

pivy certainly yes. Probably we’ll need to PR the original pivy code ourselves :wink:
coin itself I think has no python bindings

what changes are needed on pivy?

When you try to use the version of Pivy that’s distributed with, e.g. Ubuntu (even very recent versions), it depends on Shiboken2, which is Qt5. So to get it working with Qt6 we have to compile it ourselves. Which is not difficult, just annoying.

hi guys, I just looked into building pivy with py3.12 [1], but the problem here is that conda-forge has no pyside2 builds for py3.12. But there are py3.12 builds for pyside6. So I had a quick look at the pivy code, what has to be fixed for pyside6. There is one PR [2] which states that there is no qtdesigner in pyside6, but I am not sure if this is true. I would like to support both pyside2 and pyside6 side by side with pivy. Are there best practices to do so? I guess with freecad there must have been similar issues.
maybe something like a qt.py file:

try:
    from PySide2 import QtCore, QtGui
except ImportError:
    from PySide6 as QtCore, QtGui

and then using:

from pivy.qt import QtCore, QtGui

[1] https://github.com/coin3d/pivy/pull/108
[2] https://github.com/coin3d/pivy/pull/106
[3] https://github.com/search?q=repo%3Acoin3d%2Fpivy++pyside2&type=code

here is branch which should be pyside6/qt6 compatible. But I haven’t tried so far as I do not have a soqt build against qt6:

https://github.com/coin3d/pivy/tree/conda-py311%2C-py312

and here my attempts to build soqt for qt6:

https://github.com/conda-forge/soqt-feedstock/pull/18

I’m trying my hand at this as well…
I thought quarter supersedes soqt?
FWIW, I seem to be able to build pivy without soqt, but since it doesn’t appear to use quarter instead, I guess that just leads to a “dysfunctional” pivy for our purposes?

Indeed it gives me errors like this when I build FC (and the pivy used by it) without soqt:

error: invalid use of incomplete type 'PyTypeObject' {aka 'struct _typeobject'}

, but I’m not sure it’s related.

Incidentally I saw that FC configure outputs something mentioning pybind11, I’ll try whether activating that makes a difference.

No it’s totally ok to build pivy without soqt.

I don’t think this is related to pivy or soqt.


I have now published a alpha release of pivy: https://github.com/coin3d/pivy/releases/tag/0.6.9.a0 targeting python3.12 and qt6.

error: invalid use of incomplete type ‘PyTypeObject’ {aka ‘struct _typeobject’}

means you build pyside with limited python API. The default build of pyside forces limited api.

Ich have a Qt6 build on windows (https://github.com/Neumann-A/my-vcpkg-ports/issues/1#issuecomment-1858823723) but some dependencies seems to be too new for FreeCAD to deal with.

Thanks, I might pull that one in. (Since I’m doing this on NixOS I have the “luxury” of being able to reproducibly include dependencies by (almost trivially) packaging them from their commit).

Does this soqt status mean there’s no soqt needed and also not quarter?