Hello,

Sorry for is probably really dumb, simple question, 
but I've just started with Pyside/Qt.  I'm rewriting 
a small wxPython app in Pyside and am stuck on this 
point.  (I am going through Summerfield's book and 
using the Pyside/Qt docs but have not seen an answer 
although I could easily have missed it.)

My app gets data from a RDMS and thus many data items 
may be null rather than a domain value.  
For example a date field may be <2011-08-01> or null.  
I expected a null date (which is represented as a Python 
None within my program) could be used to set a QDate 
widget and would result in a blank field being shown 
but 
  my_date_widget.setDate (None)
produces a TypeError.

The Qt docs are not clear (to me) but I think say that
a null QDate is the same as an invalid QDate so I tried
the following
  qdateNull = QtCore.QDate (0, 0, 0)  # An invalid QDate object.
  # 'due' is a Python datetime.date object or None.
  if not due: 
    self.due.setDate (qdateNull)
  else:
    self.due.setDate (Qdate (due.year, due.month, due.day))
However, the "Due" field on the form shows "2000-01-01"
when the value of 'due' is None.

How the heck do I get a Qdate field to be blank when the
corresponding date value is None?

I am using Pyside 1.0.2 as that is what is currently 
provided with Fedora-15.  My question is not restricted 
to QDate objects -- the same problem arises with any
object other than ones with text values (where I can
substitute "" for None) so I'd like to know the general 
way of dealing with this issue.

Thanks.

_______________________________________________
PySide mailing list
PySide@lists.pyside.org
http://lists.pyside.org/listinfo/pyside

Reply via email to