<html><head><style type="text/css">body {word-wrap: break-word; background-color:#ffffff;}</style></head><body><div style="font-family: sans-serif; font-size: 16px"><i>Hello. I'm learning PyQt for use with Designer for database applications. <br></i><i>I've been reading all the resources and tutorials, and I have a good amount of <br></i><i>experience with GUI and Database programming in MS ACCESS. I have finally <br></i><i>decided to put in the effort to lear python and QT but i'm stuck and <br></i><i>need help seeing what I'm doing wrong. <br></i><i><br></i><i>I have Ui_</i><i><a href="http://Clients.py">Clients.py</a></i><i> generated by Eric from "clients.ui" created by Designer.<br></i><i><br></i><i>class Ui_MainWindowClients(object):<br></i><i> def setupUi(self, MainWindowClients):<br></i><i> MainWindowClients.setObjectName(_fromUtf8("MainWindowClients"))<br></i><i> MainWindowClients.resize(640, 480)<br></i><i><br></i><i>... etc<br></i><i>Among the widgets is QtGui.QTreeView "ClientTreeView" as follows:<br></i><i><br></i><i> self.ClientTreeView = QtGui.QTreeView(self.centralwidget)<br></i><i> self.ClientTreeView.setGeometry(QtCore.QRect(30, 290, 401, 111))<br></i><i><br></i><i>... etc ending with<br></i><i><br></i><i> self.ClientTreeView.setObjectName(_fromUtf8("ClientTreeView"))<br></i><i><br></i><i>I also have </i><i><a href="http://Clients.py">Clients.py</a></i><i> as generated by Eric from "clients.ui"<br></i><i><br></i><i>class MainWindowClients(QMainWindow, Ui_MainWindowClients):<br></i><i> SSN, FNAME, LNAME, SEX, RACE, DOB = range(6)<br></i><i> ASC = 0<br></i><i> DESC = 1<br></i><i> <br></i><i> def __init__(self, parent = None):<br></i><i> QMainWindow.__init__(self, parent)<br></i><i> self.setupUi(self)<br></i><i> <br></i><i> dbType = "QMYSQL"<br></i><i> dbConnect = "clientsdb"<br></i><i> dbName = "clients"<br></i><i> dbTable = "Clients"<br></i><i> dbUname = "root" #because db has been created with user name<br></i><i> dbPW = "" #because db password is not set<br></i><i> db = QSqlDatabase.addDatabase(dbType, dbConnect)<br></i><i> db.setDatabaseName(dbName)<br></i><i> db.setUserName(dbUname)<br></i><i><br></i><i> if not db.open():<br></i><i> QMessageBox.warning(None, "ClientTracking:".join(dbName), <br></i><i> QString("Database Open Error: %1").arg(db.lastError().text()))<br></i><i> sys.exit(1)<br></i><i> <br></i><i> self.clientModel = QSqlTableModel(None, db)<br></i><i> self.clientModel.setTable("Clients")<br></i><i> self.clientModel.setSort(SSN, ASC)<br></i><i> self.clientModel.select()<br></i><i> <br></i><i> self.ClientTreeView = QTreeView(self)<br></i><i> self.ClientTreeView.setModel(self.clientModel)<br></i><i> self.ClientTreeView.setGeometry(QtCore.QRect(30, 290, 401, 111))<br></i><i> self.ClientTreeView.show()<br></i><i> <br></i><i> @pyqtSignature("QString")<br></i><i> def on_cmbBoxUniqueID_editTextChanged(self, p0):<br></i><i> # TODO: not implemented yet<br></i><i>... etc <br></i><i><br></i><i>My problem is in connecting self.clientModel to self.ClientTreeView.<br></i><i>When i run this code MainWindowClients is painted including ClientTreeView <br></i><i>from Designer (blank), but instead of having the model attached to Designer's <br></i><i>widget ClientTreeView, a second QTreeview widget is created at default Geometry.<br></i><i><br></i><i><br></i><i>On a related item, also note... the code snippet in the PyQt documentation <br></i><i>explaining how to use QT Designer with PyQt contains the following for multiple <br></i><i>inheritance instancing: <br></i><i>The reference to "self.ui.okButton.clicked.connect(self.accept)" is confusing.<br></i><i>It makes sense for the simple sub-classing of QDialog presented just before, but<br></i><i>it does not help trying to figure out what my problem is...<br></i><i><br></i><i>from PyQt4.QtGui import QDialog<br></i><i>from ui_imagedialog import Ui_ImageDialog<br></i><i><br></i><i>class ImageDialog(QDialog, Ui_ImageDialog):<br></i><i> def __init__(self):<br></i><i> QDialog.__init__(self)<br></i><i><br></i><i> # Set up the user interface from Designer.<br></i><i> self.setupUi(self)<br></i><i><br></i><i> # Make some local modifications.<br></i><i> self.colorDepthCombo.addItem("2 colors (1 bit per pixel)")<br></i><i><br></i><i> # Connect up the buttons.<br></i><i> self.ui.okButton.clicked.connect(self.accept)<br></i><i> self.ui.cancelButton.clicked.connect(self.reject)<br></i><i><br></i><i>Any help will be appreciated... Thanks. I'm looking forward to using the power<br></i><i>of PyQt with MySql etc for non-MS bound projects.<br></i><i><br></i><i>Wes<br></i><i><br></i></div></body></html>