我是python的新手,我想知道如何更改为PyQt3编写的代码以在PyQt4上工作。例如:下面的代码应该可以很好地在PyQt3上工作,我应该对它做什么修改才能使它在PyQt4上工作?
谢谢。
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()发布于 2013-02-26 17:22:58
主要的差异来自Qt3和Qt4的API之间的差异,这在http://doc.qt.io/qt-4.8/porting4-overview.html和其他几个Qt移植指南中应该有相当好的介绍。
https://stackoverflow.com/questions/15071117
复制相似问题