I have written a very simple QT edit app using QTextEdit (attached). It
works with both Qt5 and Qt6, and typing Shift, Control, and Alt keys does
not cause any unexpected behavior. So whatever is happening is coming from
Leo somehow.
BTW, you said that you've been using Leo/Qt6 for some time. But I couldn't
get it to run until I fixed qt_text. How did you manage it? I don't know
what qt_text does, really, but it's imported even though it's not in my
enabled plugins list.
On Tuesday, April 13, 2021 at 11:39:46 AM UTC-4 [email protected] wrote:
> This behavior makes it impossible to do any editing in Leo/pyqt6. I can
> read the text, I can type into the body, but I can't use the ALT, SHIFT, or
> CNTRL keys if anything has been selected, and pressing the SHIFT key also
> inserts those strange glyphs so I can't type capitals. The right and left
> shift keys do the same things.
>
> I was going to capture the version/build info from the log pane, but
> pressing CNTRL-C actually inserted thes glyphs into the log pane, and only
> one line was copied.
>
> On Tuesday, April 13, 2021 at 11:10:38 AM UTC-4 Edward K. Ream wrote:
>
>> On Mon, Apr 12, 2021 at 3:49 PM [email protected] <[email protected]>
>> wrote:
>>
>>> The shift and ALT keys also do the same thing - delete the selection.
>>> The strange characters get inserted when I press <SHIFT>. This is using
>>> qt6, of course.
>>>
>>
>> Again, I see nothing like this. I've been using the qt6 code long enough
>> that I would be surprised if there were any key-related problems.
>>
>> Edward
>>
>
--
You received this message because you are subscribed to the Google Groups
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/leo-editor/ef3a6c65-2ead-4d24-9a63-4f4a8a87521en%40googlegroups.com.
import sys
qtvers = 'unknown'
try:
from PyQt6.QtWidgets import QMainWindow, QTextEdit, QApplication
from PyQt6.QtCore import Qt
qtvers = 'qt6'
except ImportError:
from PyQt5.QtWidgets import QMainWindow, QTextEdit, QApplication
from PyQt5.QtCore import Qt
qtvers='qt5'
QT5 = 'qt5'
QT6 = 'qt6'
print('Using', qtvers)
shift_modifier = Qt.ShiftModifier if qtvers == QT5 else
Qt.KeyboardModifiers.ShiftModifier
cntrl_modifier = Qt.ControlModifier if qtvers == QT5 else
Qt.KeyboardModifiers.ControlModifier
alt_modifier = Qt.AltModifier if qtvers == QT5 else
Qt.KeyboardModifiers.AltModifier
modifer_name = {shift_modifier: "SHIFT", cntrl_modifier:"CTRL",
alt_modifier: "ALT"}
class TextEdit(QTextEdit):
def __init__(self):
QTextEdit.__init__(self)
self.setPlainText(f'Using {qtvers}')
def keyPressEvent(self, event):
super(TextEdit, self).keyPressEvent(event)
do_key(event)
def do_key(key):
modifiers = key.modifiers()
ischar = key.key() < 0x110000
letter = chr(key.key()) if ischar else ''
msg = f'{modifer_name.get(modifiers)} {letter}'
print(msg)
app = QApplication(sys.argv)
textedit = TextEdit()
textedit.setWindowTitle('QTextEdit Test')
textedit.show()
sys.exit(app.exec())