pyQT question

Scott Hathaway slhath at charter.net
Thu Oct 31 00:40:19 CET 2002


I am new to pyQT and I am trying to subclass this form and add items to the
listbox.  Can anyone tell me what I am doing wrong?

Thanks,
Scott

---------- form being subclassed ---------------------
from qt import *

class frmMain(QDialog):
    def __init__(self,parent = None,name = None,modal = 0,fl = 0):
        QDialog.__init__(self,parent,name,modal,fl)

        if name == None:
            self.setName('frmMain')

        self.resize(680,540)
        self.setCaption(self.tr('MySQL Easy'))

        self.tabPages = QTabWidget(self,'tabPages')
        self.tabPages.setGeometry(QRect(110,40,540,490))

        self.tab = QWidget(self.tabPages,'tab')
        self.tabPages.insertTab(self.tab,self.tr('Host'))

        self.tab_2 = QWidget(self.tabPages,'tab_2')
        self.tabPages.insertTab(self.tab_2,self.tr('Database'))

        self.tab_3 = QWidget(self.tabPages,'tab_3')
        self.tabPages.insertTab(self.tab_3,self.tr('Query'))

        self.dbList = QListView(self,'dbList')
        self.dbList.addColumn(self.tr('Databases'))
        item = QListViewItem(self.dbList,None)
        item.setText(0,self.tr('New Item'))

        self.dbList.setGeometry(QRect(0,40,104,490))

self.dbList.setSizePolicy(QSizePolicy(0,7,self.dbList.sizePolicy().hasHeight
ForWidth()))

        self.Frame7 = QFrame(self,'Frame7')
        self.Frame7.setGeometry(QRect(0,0,650,30))
        self.Frame7.setFrameShape(QFrame.StyledPanel)
        self.Frame7.setFrameShadow(QFrame.Raised)

----------------- main script which is trying to
subclass -----------------------
from qt import *
from frmMain import *
from mysql_functions import *

class mForm (frmMain):
    def __init__(self,parent=None,name=None,modal=0,f1=0):
            frmMain.__init__(self,parent,name,f1)

    def fill_dbList(self):
        dbs = getDatabaseList()
        # the next line gives the error
        self.dbList.insertStrList(dbs)
        # here I have tried the following
        # frmMain.dbList.insertItem(dbs[0])
        # mForm.dbList.insertItem('test')

if __name__=='__main__':
    a = QApplication(sys.argv)
    QObject.connect(a,SIGNAL('lastWindowClosed()'),a,SLOT('quit()'))
    w = mForm()
    a.setMainWidget(w)
    w.fill_dbList()
    w.show()
    a.exec_loop()


Thanks for your help!
Scott Hathaway





More information about the Python-list mailing list