3

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))"

NTC
  • 56
  • 3
  • 1
    Well I don’t have these installed and I got bored digging around three+ libraries trying to work out what you should do but: 1. I very much doubt it’s `values`. There is basically one thing which you setf to be `values` and that’s `values`. 2. The api in c++ looks like it’s more a pair of arrays than an array of pairs. As your data looks 2x2 and symmetric it isn’t clear what you think you’re doing. 3. Did you try looking through the source code (e.g. `M-.` in Emacs or start by inspecting `'q+:data`). It knows there is no applicable method so surely there are applicable methods somewhere – Dan Robertson Aug 04 '18 at 17:20
  • Thank you for your answer. AFAIK, with qtools `setf` is extended to use `values` for setter functions that take multiple arguments. I was trying to pass either two lists or two vectors. According to the documentation, data should be: (1) QPolygonF; (2) const QVector& const QVector&; (3) const double* const double* int. I can't inspect 'q+:data… ("data is not external in q+ package"). I've already spent many many hours trying to figure this thing out, but having very little experience with c++, cffi, qt, commonqt, qtools, etc., I guess this is just way over my head. – NTC Aug 23 '18 at 00:20
  • Can you get to the generated code with e.g. `M-.`? Maybe you would need to turn on maximum debugging. – Dan Robertson Aug 23 '18 at 00:22

0 Answers0