Status report: suppport for qt6. Thomas, pls read

65 views
Skip to first unread message

Edward K. Ream

unread,
Jul 13, 2021, 12:36:17 PM7/13/21
to leo-editor
I have spent two long days dealing with the name changes foisted upon us by the Qt devs. More work and testing is coming. If there are major problems I may just punt on Qt6 entirely until after Leo 6.4 final.

PR #2054 shows the scale of the work involved. The ekr-qt6-2 branch contains the work. I expect to spend at least another day testing.

Thomas, I made several changes to the vr3 plugin. I had no real choice but to follow the patterns now used throughout Leo to make sense of the Qt naming horrors.

vr3 doesn't load with qt6 in the ekr-qt6-2 branch. Perhaps you are aware of this.

In embed_widget I changed explicit tests on isQt6 to a single line:

w.setWordWrapMode(WrapMode.WrapAtWordBoundaryOrAnywhere)

This might work, but I haven't tested it. Please let me know if there are problems.

Edward

tbp1...@gmail.com

unread,
Jul 13, 2021, 1:11:56 PM7/13/21
to leo-editor
OK, I'll get on it.

tbp1...@gmail.com

unread,
Jul 13, 2021, 1:14:46 PM7/13/21
to leo-editor
How did you get PyQt6.2?  The latest I got just now via pip is PyQt6-Qt6-6.1.2.

tbp1...@gmail.com

unread,
Jul 13, 2021, 1:49:57 PM7/13/21
to leo-editor
Merging ekr-qt6-2 into my own qt6 branch, Leo does not start:

File "c:\Tom\git\leo-editor\leo\plugins\nested_splitter.py", line 363, in NestedSplitter
    Orientations = QtCore.Qt.Orientations if isQt6 else QtCore.Qt
AttributeError: type object 'Qt' has no attribute 'Orientations'

Obviously it's an enumeration thing to be fixed, but how are you able to run?

tbp1...@gmail.com

unread,
Jul 13, 2021, 3:35:59 PM7/13/21
to leo-editor
Testing VR3 imports in a separate node:

import leo.plugins.qt_text as qt_text
import leo.plugins.free_layout as free_layout
from leo.core.leoQt import isQt6, isQt5, QtCore, QtWidgets
from leo.core.leoQt import phonon, QtMultimedia, QtSvg
from leo.core.leoQt import KeyboardModifier, Orientation, QAction, QActionGroup, WrapMode

exception executing script
ImportError: cannot import name 'QActionGroup' from 'leo.core.leoQt' (c:\Tom\git\leo-editor\leo\core\leoQt.py)

This seems to be one of the problems.  I'll have to find out where  QActionGroup went to.

tbp1...@gmail.com

unread,
Jul 13, 2021, 3:37:22 PM7/13/21
to leo-editor
I had to give up on the merged branch.  I checked out your branch directly, and it's running.  Now I just have to make sure I don't accidentally commit anything to it.

On Tuesday, July 13, 2021 at 1:49:57 PM UTC-4 tbp1...@gmail.com wrote:

Edward K. Ream

unread,
Jul 13, 2021, 4:14:41 PM7/13/21
to leo-editor
On Tue, Jul 13, 2021 at 12:14 PM tbp1...@gmail.com <tbp1...@gmail.com> wrote:

Hey. Thanks for looking into this.

How did you get PyQt6.2?  The latest I got just now via pip is PyQt6-Qt6-6.1.2.

Leo 6.4-devel, ekr-qt6-2 branch, build 2b52959933
2021-07-13 11:15:07 -0500
Python 3.9.6, PyQt version 6.1.1
Windows 10 AMD64 (build 10.0.19041) SP0

I got it with pip39 install pyqt6, where pip39 forces the python 3.9 version of pip.

Edward

Edward K. Ream

unread,
Jul 13, 2021, 4:18:09 PM7/13/21
to leo-editor
On Tue, Jul 13, 2021 at 2:37 PM tbp1...@gmail.com <tbp1...@gmail.com> wrote:
I had to give up on the merged branch.  I checked out your branch directly, and it's running.  Now I just have to make sure I don't accidentally commit anything to it.

The branch starts with 'ekr-', so you would have to issue a PR to change it.  And please do issue a PR if you find a problem with vr3.

Edward

tbp1...@gmail.com

unread,
Jul 13, 2021, 5:34:46 PM7/13/21
to leo-editor
I used the Python 3.9 version of pip too, and it updated me to pyqt6.11 (on Windows).

tbp1...@gmail.com

unread,
Jul 13, 2021, 5:57:19 PM7/13/21
to leo-editor
Great, VR3 now works with pyqt6.11.  But now it doesn't work with pyqt5.  Grrr.

tbp1...@gmail.com

unread,
Jul 13, 2021, 6:15:16 PM7/13/21
to leo-editor
OK, now works again with both pyqt5 and pyqt6.  PR has been issued.

Edward K. Ream

unread,
Jul 13, 2021, 6:54:09 PM7/13/21
to leo-editor
On Tue, Jul 13, 2021 at 5:15 PM tbp1...@gmail.com <tbp1...@gmail.com> wrote:
OK, now works again with both pyqt5 and pyqt6.  PR has been issued.

Hmm. The tests on isQt6 should not be necessary.  Importing QAction, QActionGroup from leoQt.py should just work. If they don't there is a real problem with my code.  Let me look into this.

I don't want to approve this PR. It would just be a confusing step backward.

Edward

tbp1...@gmail.com

unread,
Jul 13, 2021, 7:13:55 PM7/13/21
to leo-editor
I tried the imports in a stand-alone node.  They did need the version test.  This is what I ended up with after several tries -

@language python
import leo.plugins.qt_text as qt_text
import leo.plugins.free_layout as free_layout
from leo.core.leoQt import isQt6, isQt5, QtCore, QtWidgets
from leo.core.leoQt import phonon, QtMultimedia, QtSvg
from leo.core.leoQt import KeyboardModifier, Orientation
from leo.core.leoQt import QtGui, WrapMode

QActionGroup = QtGui.QActionGroup if isQt6 else QtWidgets.QActionGroup
QAction = QtGui.QAction if isQt6 else QtWidgets.QAction

When I adjusted the VR3 imports to match these, it ran.  Note that it is only the QActionGroup and QAction that had to interrogate the qt version.  Apparently they got moved from QtWidgets to QtGui.

Edward K. Ream

unread,
Jul 13, 2021, 7:35:26 PM7/13/21
to leo-editor
On Tuesday, July 13, 2021 at 6:13:55 PM UTC-5 tbp1 wrote:
I tried the imports in a stand-alone node.  They did need the version test. 

That's because of bugs in leoQt5.py and leoQt6.py :-)

Rev 6a6b50d in ekr-qt6-2 fixes those bugs, and also some import problems in vr3. Please let me know how it works for you.

Imo, it's essential that all the crappy details of accessing symbols be hidden from "client code". That is, only leoQt4.py, leoQt5.py and leoQt6.py should know, say, where QActionGroup is. We don't want to "distribute" that horror show.

Edward

tbp1...@gmail.com

unread,
Jul 13, 2021, 7:46:38 PM7/13/21
to leo-editor
On Tuesday, July 13, 2021 at 7:35:26 PM UTC-4 Edward K. Ream wrote:

Imo, it's essential that all the crappy details of accessing symbols be hidden from "client code". That is, only leoQt4.py, leoQt5.py and leoQt6.py should know, say, where QActionGroup is. We don't want to "distribute" that horror show.

I'll certainly agree with that as a goal! But we may be playing catchup forever, because I'm sure that leoQtx isn't going to be translating everything in QT.  At some future time someone may need to use one that LeoQtx doesn't know about.

I'll look at your latest version.

tbp1...@gmail.com

unread,
Jul 13, 2021, 7:52:07 PM7/13/21
to leo-editor
I see you handled QActionGroup, but not QAction.  Would you please include QAction, then I'll try it out.

Edward K. Ream

unread,
Jul 13, 2021, 7:52:50 PM7/13/21
to leo-editor
On Tue, Jul 13, 2021 at 6:46 PM tbp1...@gmail.com <tbp1...@gmail.com> wrote:

Imo, it's essential that all the crappy details of accessing symbols be hidden from "client code". That is, only leoQt4.py, leoQt5.py and leoQt6.py should know, say, where QActionGroup is. We don't want to "distribute" that horror show.

I'll certainly agree with that as a goal! But we may be playing catchup forever, because I'm sure that leoQtx isn't going to be translating everything in QT.  At some future time someone may need to use one that LeoQtx doesn't know about.

Sure. Client code is free to add Qt6/7/8 code, especially if that code has no counterpart in Qt 4 or 5.

And we can change the leoQt*.py files if that is convenient.

For now, getting the existing plugins to work will be good enough :-)

Edward

Edward K. Ream

unread,
Jul 13, 2021, 7:54:44 PM7/13/21
to leo-editor
On Tue, Jul 13, 2021 at 6:52 PM tbp1...@gmail.com <tbp1...@gmail.com> wrote:
I see you handled QActionGroup, but not QAction.  Would you please include QAction, then I'll try it out.

The leoQt*.py files do handle QAction. vr3 imports correctly with both qt5 and qt6.

However, there are some needless inconsistencies, which I'll fix later today or tomorrow.

Edward
Reply all
Reply to author
Forward
0 new messages