HI, i am trying to make a simple Pyqt application which will be a data base manager. Im using the QSqlTableModel as model, but im having trouble to do simples tasks.
import sys
from ui import * # My ui.py file
from PyQt4 import QtSql, QtGui
def __init__(self, parent=None):
QtGui.
QWidget.__init__
(self, parent
) self.ui = Ui_Dialog()
self.ui.setupUi(self)
self.model.setTable("produtos")
self.model.select()
self.ui.tableView.setModel(self.model)
QtCore.
QObject.
connect(self.
ui.
FilterButton, QtCore.
SIGNAL('clicked()'), self.
FilterRecords)
def FilterRecords(self):
text = self.ui.prodname.text()
if len(text) == 0:
... here i want to make setFilter(void) to just redisplay all table ... (1)
How could i do that ?
else:
self.model.setFilter("name = '%s'" % text)
import sys
from ui import * # My ui.py file
from PyQt4 import QtSql, QtGui
class MyForm(QtGui.QDialog):
def __init__(self, parent=None):
QtGui.QWidget.__init__(self, parent)
self.ui = Ui_Dialog()
self.ui.setupUi(self)
self.model = QtSql.QSqlTableModel(self)
self.query = QtSql.QSqlQueryModel(self)
self.model.setTable("produtos")
self.model.setEditStrategy(QtSql.QSqlTableModel.OnManualSubmit)
self.model.select()
self.ui.tableView.setModel(self.model)
QtCore.QObject.connect(self.ui.FilterButton, QtCore.SIGNAL('clicked()'), self.FilterRecords)
def FilterRecords(self):
text = self.ui.prodname.text()
if len(text) == 0:
... here i want to make setFilter(void) to just redisplay all table ... (1)
How could i do that ?
else:
self.model.setFilter("name = '%s'" % text)
To copy to clipboard, switch view to plain text mode
First port here, sorry if is a noob question. I searched on the docs, but cant find a solution.
Bookmarks