Skip to content

Instantly share code, notes, and snippets.

@dtoebe
Created January 3, 2017 11:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dtoebe/54c36c1ebf8993f2f4441604d97a410f to your computer and use it in GitHub Desktop.
Save dtoebe/54c36c1ebf8993f2f4441604d97a410f to your computer and use it in GitHub Desktop.
WRITE A SIMPLE MARKDOWN EDITOR WITH GO-QML - main.go - 2
//main.go
...
func run() error {
engine := qml.NewEngine() //Create the QML engine
engine.On("quit", func() { os.Exit(0) }) //If quit is called from QML the Golang program will gracefully quit
component, err := engine.LoadFile("assets/main.qml") //Load the QML file
if err != nil {
return err //if you cannot load the QML file return an error
}
win := component.CreateWindow(nil) //Create the window
win.Show() //Show the window
win.Wait() //Hold the window open
return nil //Once the window is closed return no error
}
func main() {
if err := qml.Run(run); err != nil { //Run the QML package
fmt.Fprintf(os.Stderr, "ERR: %v\n", err) //Output the error in your system's stderr
os.Exit(1) //Exit with a non-zero status
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment