Solved How to run code written for PyQt4 in PyQt5
-
PyQt4 does not exist any more in Ubuntu 20.04. How can I run these examples: https://www.tutorialspoint.com/pyqt/pyqt_quick_guide.htm with PyQt5??
-
Hi,
Change PyQt4 for PyQt5 and move all widgets related import to QtWidgets in place of QtGui.
-
In order to help me understand...what should I do in this example?
import sys from PyQt4.QtGui import * from PyQt4.QtCore import * def window(): app = QApplication(sys.argv) w = QWidget() b = QPushButton(w) b.setText("Hello World!") b.move(50,50) b.clicked.connect(showdialog) w.setWindowTitle("PyQt Dialog demo") w.show() sys.exit(app.exec_()) def showdialog(): d = QDialog() b1 = QPushButton("ok",d) b1.move(50,50) d.setWindowTitle("Dialog") d.setWindowModality(Qt.ApplicationModal) d.exec_() if __name__ == '__main__': window()
-
Exactly what I said:
- replace PyQt4 with PyQt5
- since all the classes are from the widgets module replace QtGui with QtWidgets
In addition: stop using star imports, it's bad habit and import stuff you do not use.
-
You are AMAZING!!! Thanx a lot!!!
-
You're welcome
Since you have it working now, please mark the thread as solved using the "Topic Tool" button so that other forum users may know a solution has been found.
-
This post is deleted!