You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Radhi Fadlillah edited this page Dec 2, 2019
·
3 revisions
To enable live reload, all we need to do is start WatchResourceDir from the Viewer. For example, open the Hello World app, then modify main.go file into like this :
package main
import (
"log""os"
fp "path/filepath""github.com/go-qamel/qamel"
)
funcmain() {
// Create applicationapp:=qamel.NewApplication(len(os.Args), os.Args)
app.SetApplicationDisplayName("Live Reload Example")
// Create a QML viewer// Here we change the source URL into relative pathview:=qamel.NewViewerWithSource("res/main.qml")
view.SetResizeMode(qamel.SizeRootObjectToView)
view.SetHeight(300)
view.SetWidth(400)
view.Show()
// Watch change in resource dirprojectDir, err:=os.Getwd()
iferr!=nil {
log.Fatalln("Failed to get working directory:", err)
}
resDir:=fp.Join(projectDir, "res")
goview.WatchResourceDir(resDir)
// Exec appapp.Exec()
}
Now build the app, and change the res/main.qml file on runtime. Live reload should be works now :