Migrating from PyQt3 to PyQt4

Post here if you need help with creating a Graphical User Interface in Python.

Migrating from PyQt3 to PyQt4

Postby flaviomosquito » Mon Feb 25, 2013 4:45 pm

Hi folks,

I am new on python and I would like to know how can I change a code written for PyQt3 to work on PyQt4. For example: the code bellow should work fine for PyQt3, what should I change on it to make it work on PyQt4?

Thanks.

Code: Select all
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()
flaviomosquito
 
Posts: 1
Joined: Mon Feb 25, 2013 4:34 pm

Re: Migrating from PyQt3 to PyQt4

Postby Yoriz » Mon Feb 25, 2013 6:16 pm

Hi, what errors do you get if you run that code with PqQT4. You should change the bits that throw up errors.
New Users, Read This
Join the #python-forum IRC channel on irc.freenode.net!
Spam topic disapproval technician
Windows7, Python 2.7.4., WxPython 2.9.5.0., some Python 3.3
User avatar
Yoriz
 
Posts: 774
Joined: Fri Feb 08, 2013 1:35 am
Location: UK


Return to GUI

Who is online

Users browsing this forum: No registered users and 2 guests