[英]Migrating from PyQt3 to PyQt4
I am new on python and I would like to know how can I change a code written for PyQt3 to work on PyQt4. 我是python新手,我想知道如何更改为PyQt3编写的代码以在PyQt4上工作。 For example: the code bellow should work fine for PyQt3, what should I change on it to make it work on PyQt4?
例如:下面的代码在PyQt3上应该可以正常工作,我应该对其进行哪些更改以使其在PyQt4上正常工作?
Thanks. 谢谢。
import sys
from qt import *
class dlgLabel(QDialog):
def __init__(self,parent = None,name = None,modal = 0,fl = 0):
QDialog.__init__(self,parent,name,modal,fl)
self.setCaption("label dialog")
if name == None:
self.setName("dlgLabel")
self.layout=QHBoxLayout(self)
self.layout.setSpacing(6)
self.layout.setMargin(11)
self.label=QLabel("&Enter some text", self)
self.edit=QLineEdit(self)
self.label.setBuddy(self.edit)
self.layout.addWidget(self.label)
self.layout.addWidget(self.edit)
self.edit.setFocus()
if __name__ == '__main__':
app = QApplication(sys.argv)
QObject.connect(app, SIGNAL('lastWindowClosed()'),
app, SLOT('quit()'))
win = dlgLabel()
app.setMainWidget(win)
win.show()
app.exec_loop()
The main differences will arise from differences between Qt 3 and Qt 4's APIs, which should be covered fairly well in http://doc.qt.io/qt-4.8/porting4-overview.html and several other Qt porting guides. 主要区别将来自Qt 3和Qt 4的API之间的差异,在http://doc.qt.io/qt-4.8/porting4-overview.html和其他一些Qt移植指南中应对此进行很好的介绍。
Checking out https://github.com/develersrl/pyqt3support might also be useful. 检出https://github.com/develersrl/pyqt3support可能也很有用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.