[commonqt-devel] No applicable method setData

Olaf Merkert olaf at m-merkert.de
Tue Mar 22 22:31:03 UTC 2011


Hi,

I sort of ported one of the Qt4 Tutorials on Models to commonqt, because I 
want to get to know both Qt4 MVC stuff and commonqt a bit.  I more or less just 
wrote the C++ Code in Lisp syntax.
However, there is an error with the bit of code that calls setData (I attached 
the relevant code):

No applicable method setData found on #<QStandardItemModel 0x00886620> with 
arguments (#<QModelIndex 0x007817A0>
                                                                                       #<QDateTime 
0x00889540>)
   [Condition of type SIMPLE-ERROR]

I tried wrapping the QDateTime object in a QVariant, but that doesn't help, I 
get a similar error:

No applicable method setData found on #<QStandardItemModel 0x008894D0> with 
arguments (#<QModelIndex 0x0088A130>
                                                                                       #<QVariant 
0x0088A2E0>)
   [Condition of type SIMPLE-ERROR]


Qt Documentation says setData expects a QVariant& as the last parameter, but I 
have no clue how to make one of these.  Also, setData works fine with strings.

I use sbcl 1.0.40.0.debian on Debian Squeeze, amd64 and the latest commonqt 
installed via quicklisp (20110320-git).

Can anybody help me? I'd like to understand where this problem comes from.

Thanks a lot,
Olaf Merkert
-------------- next part --------------
(in-package #:qt-user)

(enable-syntax)

(defparameter *mail-data*
  '(("Happy New Year!" "Grace K. <grace at software-inc.com>"
     ((2006 12 31) (17 03)))
    ( "Radically new concept" "Grace K. <grace at software-inc.com>"
     ((2006 12 22) (9 44)))
    ( "Accounts" "pascale at nospam.com"
     ((2006 12 31) (12 50)))
    ( "Expenses" "Joe Bloggs <joe at bloggs.com>"
     ((2006 12 25) (11 39)))
    ( "Re: Expenses" "Andy <andy at nospam.com>"
     ((2007 01 02) (16 05)))
    ( "Re: Accounts" "Joe Bloggs <joe at bloggs.com>"
     ((2007 01 03) (14 18)))
    ( "Re: Accounts" "Andy <andy at nospam.com>"
     ((2007 01 03) (14 26)))
    ( "Sports" "Linda Smith <linda.smith at nospam.com>"
     ((2007 01 05) (11 33)))
    ( "AW: Sports" "Rolf Newschweinstein <rolfn at nospam.com>"
     ((2007 01 05) (12 00)))
    ( "RE: Sports" "Petra Schmidt <petras at nospam.com>"
     ((2007 01 05) (12 01)))))


(defun create-mail-model (parent)
  (labels ((mk-qdate (year month day)
             (#_new QDate year month day))
           (mk-qtime (hours minutes)
             (#_new QTime hours minutes))
           (mk-datetime (m)
             (#_new QDateTime
                          (apply #'mk-qdate (first (third m)))
                          (apply #'mk-qtime (second (third m))))))
    (let ((model (#_new QStandardItemModel 0 3 parent)))
      (#_setHeaderData model 0 (#_Horizontal "Qt") "Subject")
      (#_setHeaderData model 1 (#_Horizontal "Qt") "Sender")
      (#_setHeaderData model 2 (#_Horizontal "Qt") "Date")
      ;; entries
      (dolist (m *mail-data*)
        (#_insertRow model 0)
        (#_setData model (#_index model 0 0)
                   (first m))
        (#_setData model (#_index model 0 1)
                   (second m))
        (#_setData model (#_index model 0 2)
                   ;; (#_new QVariant (mk-datetime m))))
                   (mk-datetime m)))
      model)))

(defun test-create-mail-model ()
  (create-mail-model (#_new QWidget)))


More information about the commonqt-devel mailing list