Created
January 3, 2017 11:48
-
-
Save dtoebe/54c36c1ebf8993f2f4441604d97a410f to your computer and use it in GitHub Desktop.
WRITE A SIMPLE MARKDOWN EDITOR WITH GO-QML - main.go - 2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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