Can't input non-English characters!!
-
Hi All,
I'm testing the following code on Windows but can't understand why the QLineEdit doesn't accept non-English characters input.
Any ideas?from PyQt5.QtCore import Qt, QEvent, QRegExp from PyQt5.QtWidgets import QTabBar, QTabWidget, QApplication, QLineEdit, QWidget from PyQt5.QtGui import QRegExpValidator class EditableTabBar(QTabBar): def __init__(self, parent): QTabBar.__init__(self, parent) self._editor = QLineEdit(self) self._editor.setWindowFlags(Qt.Popup) self._editor.setFocusProxy(self) self._editor.editingFinished.connect(self.handleEditingFinished) self._editor.installEventFilter(self) def eventFilter(self, widget, event): if ((event.type() == QEvent.MouseButtonPress and not self._editor.geometry().contains(event.globalPos())) or (event.type() == QEvent.KeyPress and event.key() == Qt.Key_Escape)): self._editor.hide() return True return QTabBar.eventFilter(self, widget, event) def mouseDoubleClickEvent(self, event): index = self.tabAt(event.pos()) if index >= 0: self.editTab(index) def editTab(self, index): rect = self.tabRect(index) self._editor.setFixedSize(rect.size()) self._editor.move(self.parent().mapToGlobal(rect.topLeft())) self._editor.setText(self.tabText(index)) if not self._editor.isVisible(): self._editor.show() def handleEditingFinished(self): index = self.currentIndex() if index >= 0: self._editor.hide() self.setTabText(index, self._editor.text()) class Window(QTabWidget): def __init__(self): QTabWidget.__init__(self) self.setTabBar(EditableTabBar(self)) self.addTab(QWidget(self), 'Tab One') self.addTab(QWidget(self), 'Tab Two') if __name__ == '__main__': import sys app = QApplication(sys.argv) window = Window() window.show() sys.exit(app.exec_())Thanks in advance for your help!
Regards,
Sat -
Hi,
What are your system specification ?
What version of PyQt ?
What version of Qt ?
Can you reproduce that with a simple QLineEdit ? -
Hi,
What are your system specification ?
What version of PyQt ?
What version of Qt ?
Can you reproduce that with a simple QLineEdit ? -
-
What if you remove the event filter ?
-
Can you show an example of non-ascii char that fails ?
Just tested with àüè and such and it worked fine but on macOS.
-
Can you show an example of non-ascii char that fails ?
Just tested with àüè and such and it worked fine but on macOS.