Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Can't input non-English characters!!

Can't input non-English characters!!

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 2 Posters 2.4k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    ShinSat
    wrote on last edited by ShinSat
    #1

    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

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      What are your system specification ?
      What version of PyQt ?
      What version of Qt ?
      Can you reproduce that with a simple QLineEdit ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      S 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        What are your system specification ?
        What version of PyQt ?
        What version of Qt ?
        Can you reproduce that with a simple QLineEdit ?

        S Offline
        S Offline
        ShinSat
        wrote on last edited by ShinSat
        #3

        @SGaist pyqt5.9.1 on windows7. Interrstingly simple qlineedit works on a simplified widget in different app.
        I found copy&paste works but key-in not.
        Not sure if there is a configuration controlling the behavior...

        1 Reply Last reply
        0
        • S Offline
          S Offline
          ShinSat
          wrote on last edited by ShinSat
          #4

          Since QLineEdit works alone on my env, it may be a QTabBar issue???
          But until editingFinished singnal fired from QLineEdit , QLineEdit should be responsible for that, right?
          Still investigating what's going on, but have no idea for now. :<

          Sat

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            What if you remove the event filter ?

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            S 1 Reply Last reply
            0
            • SGaistS SGaist

              What if you remove the event filter ?

              S Offline
              S Offline
              ShinSat
              wrote on last edited by
              #6

              @SGaist No change. :<

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #7

                Can you show an example of non-ascii char that fails ?

                Just tested with àüè and such and it worked fine but on macOS.

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                S 1 Reply Last reply
                0
                • SGaistS SGaist

                  Can you show an example of non-ascii char that fails ?

                  Just tested with àüè and such and it worked fine but on macOS.

                  S Offline
                  S Offline
                  ShinSat
                  wrote on last edited by
                  #8

                  @SGaist Actually, it doesn't fail, just nothing happened when I key in Japanese characters such as あいうえお. Since I can copy&paste the problematic characters, it may be an environment issue(eg. Windows)??

                  Thanks,
                  Sat

                  1 Reply Last reply
                  0

                  • Login

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved