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.
Due to the reasons discussed here we will be moving to python-forum.io/ on October 1 2016
This forum will be locked down and no one will be able to post/edit/create threads, etc. here from thereafter. Please create an account at the new site to continue discussion.
User avatar
Yoriz
 
Posts: 1672
Joined: Fri Feb 08, 2013 1:35 am
Location: UK


Return to GUI

Who is online

Users browsing this forum: Google [Bot] and 2 guests