PkgDoc: http://godoc.org/github.com/chai2010/qml
Install Go1.4
and Qt5
and GCC
(MinGW
download here) at first.
If Qt5 is Visual Studio
version (windows only), also need install
Visual Studio
.
Then run these commands:
- set
$(QTDIR)
and add$(QTDIR)/bin
to$(PATH)
go get -d github.com/chai2010/qml
go generate
andgo install
go run hello.go
Install opengl-x.y
: go generate github.com/chai2010/qml/gl/x.y
.
Note
If use Go1.3, should run cmd /c call internal\goqml\build_msvc.bat
(windows) or cd internal/goqml && make -f Makefile.posix
istead of go generate
.
See:
- http://tip.golang.org/cmd/go/#hdr-Generate_Go_files_by_processing_source
- https://github.com/chai2010/qml/blob/master/generate_windows.go
- https://github.com/chai2010/qml/blob/master/generate_generic.go
package main
import (
"fmt"
"os"
"github.com/chai2010/qml"
)
func main() {
if err := qml.Run(run); err != nil {
fmt.Fprintf(os.Stderr, "error: %v\n", err)
os.Exit(1)
}
}
func run() error {
engine := qml.NewEngine()
engine.On("quit", func() { os.Exit(0) })
component, err := engine.LoadString("hello.qml", qmlHello)
if err != nil {
return err
}
window := component.CreateWindow(nil)
window.Show()
window.Wait()
return nil
}
const qmlHello = `
import QtQuick 2.0
Rectangle {
id: page
width: 320; height: 240
color: "lightgray"
Text {
id: helloText
text: "Hello world!"
y: 30
anchors.horizontalCenter: page.horizontalCenter
font.pointSize: 24; font.bold: true
}
}
`
Hello
Clocks
SameGame
Report bugs to [email protected].
Thanks!