Hi
I have a QTableView that is showing some data from a MySQL database and I am 
trying to use it to add new values to the table.
How can I preload some of the fields with available information like UserName 
and date rather than asking user to enter it.
I tried to preset in  

 def setModelData(self, editor, model, index):
        if index.column() == WDAY:
            data= "9" #just trying
            model.setData(index, QVariant(data))
        else:
            QSqlRelationalDelegate.setModelData(self, editor, model,
                                                index)

but unless user clickes on the cell the data is not filled in.

Or can I use (From Qt Assistant)
-----------------------------------------------------
bool QSqlRelationalTableModel::setData ( const QModelIndex & index, const 
QVariant & value, int role = Qt::EditRole ) 
Sets the data for the role in the item with the specified index to the value 
given. Depending on the edit strategy, the value might be applied to the 
database at once, or it may be cached in the model.
Returns true if the value could be set, or false on error (for example, if 
index is out of bounds).
For relational columns, value must be the index, not the display value.
----------------------------------------------------------
I tried to use this method and could not make it to work 
----
 if index.column() == WDAY:
            date = self.calenderDay.selectedDate()
            data =  date.day()
            if (self.hourModel.setData(index ,Qvariant(data) , 
Qt.DisplayRole)):
                print "Error setData %s" % (hourModel.lastError()).text()
----
I just Picked up the Rapid GUI Programming With PyQt a few week back and am 
certainly a Newbee at Python.

Regards,
Anil K Thankappan
[EMAIL PROTECTED]
Visit our website :gallery.phoenixitsolutions.com.au 
_______________________________________________
PyQt mailing list    [email protected]
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Reply via email to