Note that there are some explanatory texts on larger screens.

plurals
  1. POPyQt4 QTableView model based
    primarykey
    data
    text
    <p>I am trying to display some simple info from SQLite database into QTableView. I have followed <a href="https://stackoverflow.com/questions/8923562/getting-data-from-selected-item-in-qlistview">one answer from SO</a>, and for itself, it is working. When I try to implement the same code into my GUI (just a simple mainwindow with a QTableView object) it shows nothing. Here is the code:</p> <pre><code>from PyQt4 import QtCore, QtGui from gui import Ui_MainWindow from dialog import Ui_Dialog from PyQt4.QtSql import QSqlQueryModel,QSqlDatabase,QSqlQuery import sys class Glavni(QtGui.QMainWindow): def __init__(self, parent=None): super(Glavni, self).__init__() self.ui=Ui_MainWindow() self.ui.setupUi(self) self.show() #QtCore.QObject.connect(self.ui.actionRegistar, QtCore.SIGNAL("triggered()"), self.popup) db = QSqlDatabase.addDatabase("QSQLITE") db.setDatabaseName("baza.db") db.open() projectModel = QSqlQueryModel() projectModel.setQuery("select name from people",db) projectView = QtGui.QTableView() projectView.setModel(projectModel) projectView.show() def popup(self): dialog = QtGui.QDialog() dialog.show() class Dialog(QtGui.QDialog): def __init__(self,parent=None): super(Dialog,self).__init__() self.ui = Ui_Dialog() self.ui.setupUi(self) self.show() def main(): app = QtGui.QApplication(sys.argv) prozor = Glavni() sys.exit(app.exec_()) if __name__ == '__main__': main() </code></pre> <p>What am I doing wrong? QListView's name in QT Designer is lista, if that is relavant. Thank you.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload