Improved example
This commit is contained in:
parent
412c528a27
commit
c286c10fd1
|
@ -5,10 +5,16 @@ import QtQuick.Controls 2.15
|
||||||
|
|
||||||
Window {
|
Window {
|
||||||
id: window
|
id: window
|
||||||
|
objectName: "window"
|
||||||
visible: true
|
visible: true
|
||||||
width: 800
|
width: 800
|
||||||
height: 600
|
height: 600
|
||||||
RowLayout {
|
signal close
|
||||||
|
onVisibilityChanged: {
|
||||||
|
if(visibility == Window.Hidden)
|
||||||
|
close()
|
||||||
|
}
|
||||||
|
ColumnLayout {
|
||||||
id: rowlayout
|
id: rowlayout
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
spacing: 30
|
spacing: 30
|
||||||
|
@ -19,16 +25,20 @@ Window {
|
||||||
color: "lightgray"
|
color: "lightgray"
|
||||||
Text {
|
Text {
|
||||||
id: helloText
|
id: helloText
|
||||||
|
objectName: "helloText"
|
||||||
text: "Hello World!"
|
text: "Hello World!"
|
||||||
y: 30
|
y: 30
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
font.pointSize: 24; font.bold: true
|
font.pointSize: 24; font.bold: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ColumnLayout {
|
RowLayout {
|
||||||
spacing: 15
|
spacing: 15
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
|
Text {
|
||||||
|
text: qsTr("Change the text above:")
|
||||||
|
}
|
||||||
TextField {
|
TextField {
|
||||||
id: nameInputField
|
id: nameInputField
|
||||||
objectName: "nameInputField"
|
objectName: "nameInputField"
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
(import
|
(import
|
||||||
|
(chicken base)
|
||||||
|
srfi-18
|
||||||
(qml core)
|
(qml core)
|
||||||
coops)
|
coops)
|
||||||
|
|
||||||
|
@ -21,15 +23,28 @@
|
||||||
(load-url engine loc)
|
(load-url engine loc)
|
||||||
|
|
||||||
(define nameInputField (find-child (root engine) "nameInputField"))
|
(define nameInputField (find-child (root engine) "nameInputField"))
|
||||||
|
(define helloText (find-child (root engine) "helloText"))
|
||||||
|
;; TODO: Why does the following not work?
|
||||||
|
(define window (find-child (root engine) "window"))
|
||||||
|
|
||||||
(define (textChangeCallback cbdata argv) void
|
(define (textChangeCallback cbdata argv) void
|
||||||
(print "Text changed to " (to (property nameInputField "text") string:)))
|
(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))
|
||||||
|
|
||||||
(define conn2 (connect nameInputField "textEdited()"
|
(define conn2 (connect nameInputField "textEdited()"
|
||||||
textChangeCallback
|
textChangeCallback
|
||||||
textchange-cbdata
|
textchange-cbdata
|
||||||
(qt-connection-type auto:)))
|
(qt-connection-type auto:)))
|
||||||
|
|
||||||
|
(define conn3 (connect (root engine) "close()"
|
||||||
|
closeProgram #f
|
||||||
|
(qt-connection-type auto:)))
|
||||||
|
|
||||||
(do ((loop #t))
|
(do ((loop #t))
|
||||||
((not loop) #t)
|
((not loop) #t)
|
||||||
|
(thread-sleep! (seconds->time (+ 0.05 (time->seconds (current-time)))))
|
||||||
(process-events-timed (qevent-loop-process-event-flag process-all-events:) 50))
|
(process-events-timed (qevent-loop-process-event-flag process-all-events:) 50))
|
||||||
|
|
|
@ -416,7 +416,8 @@
|
||||||
(dos_qobject_disconnect_with_connection_static (slot-value qmoc 'ptr)))
|
(dos_qobject_disconnect_with_connection_static (slot-value qmoc 'ptr)))
|
||||||
|
|
||||||
(define-method (delete-pointer (qmoc <QMetaObjectConnection>))
|
(define-method (delete-pointer (qmoc <QMetaObjectConnection>))
|
||||||
;; TODO: try-catch disconnect
|
(handle-exceptions exn #t
|
||||||
|
(disconnect qmoc))
|
||||||
(object-release (pointer->object (alist-ref intern-data-pointer: (hash-table-ref lambda-static-callbacks (callback-key qmoc)))))
|
(object-release (pointer->object (alist-ref intern-data-pointer: (hash-table-ref lambda-static-callbacks (callback-key qmoc)))))
|
||||||
(hash-table-delete! lambda-static-callbacks (callback-key qmoc))
|
(hash-table-delete! lambda-static-callbacks (callback-key qmoc))
|
||||||
(dos_qmetaobject_connection_delete (slot-value qmoc 'ptr)))
|
(dos_qmetaobject_connection_delete (slot-value qmoc 'ptr)))
|
||||||
|
|
Loading…
Reference in New Issue