本文整理匯總了Golang中github.com/niemeyer/qml.Init函數的典型用法代碼示例。如果您正苦於以下問題:Golang Init函數的具體用法?Golang Init怎麽用?Golang Init使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Init函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: run
func run() error {
qml.Init(nil)
engine := qml.NewEngine()
engine.AddImageProvider("pwd", func(id string, width, height int) image.Image {
f, err := os.Open(id)
if err != nil {
panic(err)
}
defer f.Close()
image, err := png.Decode(f)
if err != nil {
panic(err)
}
return image
})
component, err := engine.LoadFile("imgprovider.qml")
if err != nil {
return err
}
win := component.CreateWindow(nil)
win.Show()
win.Wait()
return nil
}
示例2: run
func run(filename string) error {
qml.Init(nil)
engine := qml.NewEngine()
model, err := Read("model/gopher.obj")
if err != nil {
return err
}
qml.RegisterTypes("GoExtensions", 1, 0, []qml.TypeSpec{{
Init: func(g *Gopher, obj qml.Object) {
g.Object = obj
g.model = model
},
}})
component, err := engine.LoadFile(filename)
if err != nil {
return err
}
win := component.CreateWindow(nil)
win.Set("x", 560)
win.Set("y", 320)
win.Show()
win.Wait()
return nil
}
示例3: run
func run() error {
qml.Init(nil)
engine := qml.NewEngine()
component, err := engine.LoadFile("samegame.qml")
if err != nil {
return err
}
game := Game{
MaxColumn: MAX_COL,
MaxRow: MAX_ROW,
MaxIndex: MAX_COL * MAX_ROW,
}
context := engine.Context()
context.SetVar("game", &game)
win := component.CreateWindow(nil)
blockComponent, err := engine.LoadFile("Block.qml")
if err != nil {
return err
}
block := &Block{Component: blockComponent}
game.Block = block
game.Score = win.Root().ObjectByName("score")
win.Show()
win.Wait()
return nil
}
示例4: run
func run() error {
qml.Init(nil)
engine := qml.NewEngine()
component, err := engine.LoadFile(os.Args[1])
if err != nil {
return err
}
window := component.CreateWindow(nil)
window.Show()
window.Wait()
return nil
}
示例5: main
func main() {
qml.Init(nil)
engine := qml.NewEngine()
engine.On("quit", func() { os.Exit(0) })
component, err := engine.LoadFile("basiclayout.qml")
if err != nil {
fmt.Println(err)
return
}
window := component.CreateWindow(nil)
window.Show()
window.Wait()
}
示例6: run
func run() error {
qml.Init(nil)
engine := qml.NewEngine()
component, err := engine.LoadString("webview.qml", webview)
if err != nil {
return err
}
ctrl := &Control{
done: make(chan error),
win: component.CreateWindow(nil),
}
engine.Context().SetVar("ctrl", ctrl)
root := ctrl.win.Root()
root.On("loadingChanged", ctrl.Snapshot)
root.Set("url", os.Args[1])
ctrl.win.Show()
return <-ctrl.done
}
示例7: run
func run() error {
qml.Init(nil)
qml.RegisterTypes("GoExtensions", 1, 0, []qml.TypeSpec{{
Init: func(r *GoRect, obj qml.Object) { r.Object = obj },
}})
engine := qml.NewEngine()
component, err := engine.LoadFile("painting.qml")
if err != nil {
return err
}
win := component.CreateWindow(nil)
win.Show()
win.Wait()
return nil
}
示例8: run
func run() error {
qml.Init(nil)
qml.RegisterTypes("GoExtensions", 1, 0, []qml.TypeSpec{{
Name: "GoRect",
New: func() interface{} { return &GoRect{} },
}})
engine := qml.NewEngine()
component, err := engine.LoadFile("painting.qml")
if err != nil {
return err
}
win := component.CreateWindow(nil)
win.Show()
win.Wait()
return nil
}
示例9: run
func run() error {
qml.Init(nil)
engine := qml.NewEngine()
colors := &Colors{}
engine.Context().SetVar("colors", colors)
component, err := engine.LoadFile("delegate.qml")
if err != nil {
return err
}
window := component.CreateWindow(nil)
window.Show()
go func() {
n := func() uint8 { return uint8(rand.Intn(256)) }
for i := 0; i < 100; i++ {
colors.Add(color.RGBA{n(), n(), n(), 0xff})
time.Sleep(1 * time.Second)
}
}()
window.Wait()
return nil
}
示例10: main
func main() {
qml.Init(nil)
engine := qml.NewEngine()
component, err := engine.LoadFile("particle.qml")
if err != nil {
panic(err)
}
ctrl := Control{Message: "Hello from Go!"}
context := engine.Context()
context.SetVar("ctrl", &ctrl)
window := component.CreateWindow(nil)
ctrl.Root = window.Root()
rand.Seed(time.Now().Unix())
window.Show()
window.Wait()
}
示例11: run
func run() error {
qml.Init(nil)
qml.RegisterTypes("GoExtensions", 1, 0, []qml.TypeSpec{{
Init: func(v *GoType, obj qml.Object) {},
}, {
Init: func(v *GoSingleton, obj qml.Object) { v.Event = "birthday" },
Singleton: true,
}})
engine := qml.NewEngine()
component, err := engine.LoadFile("customtype.qml")
if err != nil {
return err
}
value := component.Create(nil)
fmt.Println("Text is:", value.Interface().(*GoType).Text)
return nil
}
示例12: run
func run() error {
qml.Init(nil)
qml.RegisterTypes("GoExtensions", 1, 0, []qml.TypeSpec{{
Name: "GoType",
New: func() interface{} { return &GoType{} },
}, {
Name: "GoSingleton",
New: func() interface{} { return &GoSingleton{Event: "birthday"} },
Singleton: true,
}})
engine := qml.NewEngine()
component, err := engine.LoadFile("customtype.qml")
if err != nil {
return err
}
value := component.Create(nil)
fmt.Println("Text is:", value.Interface().(*GoType).Text)
return nil
}
示例13: main
func main() {
qml.Init(nil)
engine := qml.NewEngine()
engine.On("quit", func() {
fmt.Println("quit")
os.Exit(0)
})
component, err := engine.LoadFile("basiclayout.qml")
if err != nil {
fmt.Println(err)
return
}
ctrl := Control{Polje1: "Hello from Go!", Polje2: "tekst2"}
context := engine.Context()
context.SetVar("ctrl", &ctrl)
window := component.CreateWindow(nil)
ctrl.Root = window.Root()
window.Show()
window.Wait()
}
示例14: run
func run() error {
qml.Init(nil)
engine := qml.NewEngine()
base, err := engine.LoadFile("base.qml")
if err != nil {
return err
}
rect, err := engine.LoadFile("rect.qml")
if err != nil {
return err
}
win := base.CreateWindow(nil)
obj := rect.Create(nil)
obj.Set("parent", win.Root())
win.Show()
win.Wait()
return nil
}
示例15: loop
func (t *tbfe) loop() {
qml.Init(nil)
engine := qml.NewEngine()
engine.Context().SetVar("lines", t)
engine.Context().SetVar("frontend", t)
engine.Context().SetVar("editor", backend.GetEditor())
backend.OnNew.Add(func(v *backend.View) {
fv := &frontendView{bv: v}
v.Buffer().AddCallback(fv.bufferChanged)
v.Settings().AddOnChange("blah", func(name string) {
if name == "lime.syntax.updated" {
// force redraw, as the syntax regions might have changed...
for i := range fv.FormattedLine {
fv.formatLine(i)
}
}
})
t.views[v] = fv
t.Len = len(t.views)
qml.Changed(t, &t.Len)
})
ed := backend.GetEditor()
ed.SetFrontend(t)
ed.LogInput(false)
ed.LogCommands(false)
c := ed.Console()
t.Console = &frontendView{bv: c}
c.Buffer().AddCallback(t.Console.bufferChanged)
if sc, err := textmate.LoadTheme("../../3rdparty/bundles/TextMate-Themes/GlitterBomb.tmTheme"); err != nil {
log4go.Error(err)
} else {
scheme = sc
}
defer func() {
fmt.Println(util.Prof)
}()
w := ed.NewWindow()
v := w.OpenFile("main.go", 0)
v.Settings().Set("trace", true)
v.Settings().Set("syntax", "../../3rdparty/bundles/go.tmbundle/Syntaxes/Go.tmLanguage")
c.Buffer().AddCallback(t.scroll)
sel := v.Sel()
sel.Clear()
sel.Add(Region{0, 0})
{
w, h := 800, 600
t.lock.Lock()
t.layout[v] = layout{0, 0, w, h - console_height - 1, Region{}, 0}
t.layout[c] = layout{0, h - console_height + 1, w, console_height - 5, Region{}, 0}
t.lock.Unlock()
t.Show(v, Region{1, 1})
}
t.Show(v, Region{100, 100})
t.Show(v, Region{1, 1})
// t.Len, _ = v.Buffer().RowCol(v.Buffer().Size())
ed.Init()
sublime.Init()
component, err := engine.LoadFile("main.qml")
if err != nil {
log4go.Exit(err)
}
window := component.CreateWindow(nil)
window.Show()
log4go.Debug("Done")
window.Wait()
}