From eafc078d2885493a27ada7bc584eea94118e7b80 Mon Sep 17 00:00:00 2001 From: kumattau Date: Fri, 26 Nov 2021 23:03:32 +0900 Subject: [PATCH] Map exec_ to their non-deprecated alternatives --- qtpy/QtCore.py | 6 ++++++ qtpy/QtGui.py | 6 +++++- qtpy/QtPrintSupport.py | 3 +++ qtpy/QtSql.py | 4 ++++ qtpy/QtWidgets.py | 5 +++++ 5 files changed, 23 insertions(+), 1 deletion(-) diff --git a/qtpy/QtCore.py b/qtpy/QtCore.py index f5487d0e..b195d8c5 100644 --- a/qtpy/QtCore.py +++ b/qtpy/QtCore.py @@ -61,6 +61,12 @@ Qt.TextColorRole = Qt.ForegroundRole Qt.MidButton = Qt.MiddleButton + # Map DeprecationWarning methods + QCoreApplication.exec_ = QCoreApplication.exec + QEventLoop.exec_ = QEventLoop.exec + QThread.exec_ = QThread.exec + QTextStreamManipulator.exec_ = QTextStreamManipulator.exec + elif PYSIDE2: from PySide2.QtCore import * diff --git a/qtpy/QtGui.py b/qtpy/QtGui.py index 62344572..253925c5 100644 --- a/qtpy/QtGui.py +++ b/qtpy/QtGui.py @@ -12,7 +12,7 @@ if PYQT6: - from PyQt6 import QtGui + from PyQt6 import QtGui from PyQt6.QtGui import * # Map missing/renamed methods @@ -31,5 +31,9 @@ elif PYSIDE6: from PySide6.QtGui import * QFontMetrics.width = QFontMetrics.horizontalAdvance + + # Map DeprecationWarning methods + QDrag.exec_ = QDrag.exec + QGuiApplication.exec_ = QGuiApplication.exec else: raise PythonQtError('No Qt bindings could be found') diff --git a/qtpy/QtPrintSupport.py b/qtpy/QtPrintSupport.py index 53253f9e..85cbb981 100644 --- a/qtpy/QtPrintSupport.py +++ b/qtpy/QtPrintSupport.py @@ -20,6 +20,9 @@ QPrintPreviewWidget.print_ = QPrintPreviewWidget.print elif PYSIDE6: from PySide6.QtPrintSupport import * + # Map DeprecationWarning methods + QPageSetupDialog.exec_ = QPageSetupDialog.exec + QPrintDialog.exec_ = QPrintDialog.exec elif PYSIDE2: from PySide2.QtPrintSupport import * else: diff --git a/qtpy/QtSql.py b/qtpy/QtSql.py index e567ba3b..3cdaaf33 100644 --- a/qtpy/QtSql.py +++ b/qtpy/QtSql.py @@ -18,6 +18,10 @@ QSqlResult.exec_ = QSqlResult.exec elif PYSIDE6: from PySide6.QtSql import * + # Map DeprecationWarning methods + QSqlDatabase.exec_ = QSqlDatabase.exec + QSqlQuery.exec_ = QSqlQuery.exec + QSqlResult.exec_ = QSqlResult.exec elif PYSIDE2: from PySide2.QtSql import * else: diff --git a/qtpy/QtWidgets.py b/qtpy/QtWidgets.py index 2734e780..dfdff016 100644 --- a/qtpy/QtWidgets.py +++ b/qtpy/QtWidgets.py @@ -44,6 +44,11 @@ QTextEdit.tabStopWidth = QTextEdit.tabStopDistance QPlainTextEdit.setTabStopWidth = QPlainTextEdit.setTabStopDistance QPlainTextEdit.tabStopWidth = QPlainTextEdit.tabStopDistance + + # Map DeprecationWarning methods + QApplication.exec_ = QApplication.exec + QDialog.exec_ = QDialog.exec + QMenu.exec_ = QMenu.exec elif PYSIDE2: from PySide2.QtWidgets import * else: