qml-old/examples/helloworld.scm

51 lines
1.6 KiB
Scheme
Raw Normal View History

2022-02-03 14:02:59 +00:00
(import
2022-02-05 12:38:15 +00:00
(chicken base)
srfi-18
2022-02-03 14:02:59 +00:00
(qml core)
coops)
2021-04-10 09:43:03 +00:00
(gui-application-create)
(define engine (make <QQmlApplicationEngine>))
(define (windowLoadCallback cbdata argv) void
(print cbdata)
(print "Loaded QML file: " (to (cadr argv) string:)))
2022-02-03 14:02:59 +00:00
(define callback-data "Test")
2022-02-04 17:47:36 +00:00
(define textchange-cbdata "Text Edited")
2022-02-03 14:02:59 +00:00
2022-02-04 17:47:36 +00:00
(define conn (connect engine "objectCreated(QObject*,QUrl)"
windowLoadCallback
callback-data
(qt-connection-type auto:)))
2022-02-03 14:02:59 +00:00
(define loc (new-QUrl "examples/helloworld.qml"))
(load-url engine loc)
2022-02-04 17:47:36 +00:00
(define nameInputField (find-child (root engine) "nameInputField"))
2022-02-05 12:38:15 +00:00
(define helloText (find-child (root engine) "helloText"))
;; TODO: Why does the following not work?
(define window (find-child (root engine) "window"))
2022-02-04 17:52:23 +00:00
(define (textChangeCallback cbdata argv) void
2022-02-05 12:38:15 +00:00
(print "Text changed to " (to (property nameInputField "text") string:))
(set-property helloText "text" (property nameInputField "text")))
(define (closeProgram cbdata argv) void
(print "Window closed, exiting program.")
(exit 0))
2022-02-04 17:52:23 +00:00
2022-02-04 17:47:36 +00:00
(define conn2 (connect nameInputField "textEdited()"
textChangeCallback
textchange-cbdata
(qt-connection-type auto:)))
2022-02-05 12:38:15 +00:00
(define conn3 (connect (root engine) "close()"
closeProgram #f
(qt-connection-type auto:)))
2021-04-10 09:43:03 +00:00
(do ((loop #t))
((not loop) #t)
2022-02-05 12:38:15 +00:00
(thread-sleep! (seconds->time (+ 0.05 (time->seconds (current-time)))))
2021-04-10 09:43:03 +00:00
(process-events-timed (qevent-loop-process-event-flag process-all-events:) 50))