Qtools and qwt curve plot: how to add points?

459 views Asked by At

I'm trying to create a QT4/qwt5 curve plot using Common Lisp and the Qtools library.

Here's a stripped down version of what I got so far:

(define-widget main-window (QWidget)
  ())

(define-subwidget (main-window plot) (q+:make-qwtplot main-window))
(define-subwidget (main-window c1) (q+:make-qwtplotcurve "data")
  (setf (q+:data c1)
    ;... -> what goes here?
  (q+:attach c1 plot))

(define-subwidget (main-window layout) (q+:make-qvboxlayout main-window)
  (q+:add-widget layout plot))

(defun main () (with-main-window (window 'main-window)))

An empty graph shows up ok, but how can I add the data?

I tried:

(setf (q+:data c1)
      (values '(1.0 1.0) '(2.0 2.0) 2))

and

(setf (q+:data c1)
      (values #(1.0 1.0) #(2.0 2.0) 2))

which produces: No applicable method setData found on # with arguments ((1.0 1.0) (2.0 2.0) 2)

I also tried passing it a QPolygonF but I don't know how to properly construct it. It works with an empty QPolygonF, but how can I then add points? The documentation recommends using the streaming operator to add points, but what's the equivalent from lisp/qtools?

I also tried creating a QwtArrayData object, for example:

(q+:make-qwtarraydata #(1.0 2.0) #(1.0 2.0))

Which produces the error: "No applicable constructor QwtArrayData found for arguments (#(1.0 2.0) #(1.0 2.0))"

0

There are 0 answers