aboutsummaryrefslogtreecommitdiffstats
path: root/examples/corelib/tools/codecs/codecs.py
diff options
context:
space:
mode:
Diffstat (limited to 'examples/corelib/tools/codecs/codecs.py')
-rw-r--r--examples/corelib/tools/codecs/codecs.py21
1 files changed, 12 insertions, 9 deletions
diff --git a/examples/corelib/tools/codecs/codecs.py b/examples/corelib/tools/codecs/codecs.py
index 5139bb6db..63e74a60b 100644
--- a/examples/corelib/tools/codecs/codecs.py
+++ b/examples/corelib/tools/codecs/codecs.py
@@ -42,7 +42,7 @@
"""PySide2 port of the widgets/tools/codecs example from Qt v5.x"""
-from PySide2 import QtCore, QtGui, QtWidgets
+from PySide2 import QtCore, QtWidgets
def codec_name(codec):
@@ -123,7 +123,8 @@ class MainWindow(QtWidgets.QMainWindow):
def findCodecs(self):
codecMap = []
- iso8859RegExp = QtCore.QRegExp('ISO[- ]8859-([0-9]+).*')
+ iso8859RegExp = QtCore.QRegularExpression('^ISO[- ]8859-([0-9]+).*$')
+ assert iso8859RegExp.isValid()
for mib in QtCore.QTextCodec.availableMibs():
codec = QtCore.QTextCodec.codecForMib(mib)
@@ -134,13 +135,15 @@ class MainWindow(QtWidgets.QMainWindow):
rank = 1
elif sortKey.startswith('UTF-16'):
rank = 2
- elif iso8859RegExp.exactMatch(sortKey):
- if len(iso8859RegExp.cap(1)) == 1:
- rank = 3
- else:
- rank = 4
else:
- rank = 5
+ match = iso8859RegExp.match(sortKey)
+ if match.hasMatch():
+ if len(match.captured(1)) == 1:
+ rank = 3
+ else:
+ rank = 4
+ else:
+ rank = 5
codecMap.append((str(rank) + sortKey, codec))
@@ -164,7 +167,7 @@ class MainWindow(QtWidgets.QMainWindow):
self.aboutAct = QtWidgets.QAction("&About", self, triggered=self.about)
self.aboutQtAct = QtWidgets.QAction("About &Qt", self,
- triggered=QtWidgets.qApp.aboutQt)
+ triggered=qApp.aboutQt)
def createMenus(self):
self.saveAsMenu = QtWidgets.QMenu("&Save As", self)