mirror of
https://gitlab.com/eql/EQL5.git
synced 2026-01-06 09:12:47 -08:00
revison of :quick example "painted item"
This commit is contained in:
parent
fcf63fd14f
commit
7b8dcfcbb4
2 changed files with 9 additions and 7 deletions
|
|
@ -22,7 +22,7 @@ it automatically.
|
|||
|
||||
Example:
|
||||
|
||||
(defparameter *item* (first (children (root-item))))
|
||||
(qml-set *item* "fillColor" "yellow")
|
||||
(|update| *item*)
|
||||
(let ((item (first (children (root-item)))))
|
||||
(qml-set item "fillColor" "yellow")
|
||||
(|update| item))
|
||||
|
||||
|
|
|
|||
|
|
@ -14,14 +14,17 @@
|
|||
|
||||
(use-package :qml)
|
||||
|
||||
(defvar *clock* nil)
|
||||
(defun clock ()
|
||||
;; will keep working even after reloading the QML file (see QML:RELOAD);
|
||||
;; if stored in a variable, this won't be true;
|
||||
(find-quick-item "clock"))
|
||||
|
||||
;; paint
|
||||
|
||||
(defun qml:paint (item painter)
|
||||
"This function is called on every 'paint' request of QML type 'PaintedItem'."
|
||||
(|setRenderHint| painter |QPainter.Antialiasing|)
|
||||
(cond ((qeql *clock* item)
|
||||
(cond ((qeql (clock) item)
|
||||
(clock:paint item painter))
|
||||
(t
|
||||
(|fillRect| painter (|contentsBoundingRect| item)
|
||||
|
|
@ -33,9 +36,8 @@
|
|||
(|setSource| (|fromLocalFile.QUrl| "qml/painted-item.qml"))
|
||||
(|setResizeMode| |QQuickView.SizeRootObjectToView|)
|
||||
(|resize| '(340 340)))
|
||||
(setf *clock* (find-quick-item "clock"))
|
||||
(let ((timer (qnew "QTimer")))
|
||||
(qconnect timer "timeout()" (lambda () (|update| *clock*))) ; repaint
|
||||
(qconnect timer "timeout()" (lambda () (|update| (clock)))) ; repaint
|
||||
(|start| timer (* 60 1000))) ; once a minute
|
||||
(|show| qml:*quick-view*))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue