本文整理匯總了Golang中github.com/niemeyer/qml.NewEngine函數的典型用法代碼示例。如果您正苦於以下問題:Golang NewEngine函數的具體用法?Golang NewEngine怎麽用?Golang NewEngine使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了NewEngine函數的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: SetUpTest
func (s *S) SetUpTest(c *C) {
qml.SetLogger(c)
qml.CollectStats(true)
qml.ResetStats()
stats := qml.Stats()
if stats.EnginesAlive > 0 || stats.ValuesAlive > 0 || stats.ConnectionsAlive > 0 {
panic(fmt.Sprintf("Test started with values alive: %#v\n", stats))
}
s.engine = qml.NewEngine()
s.context = s.engine.Context()
}
示例6: 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()
}
示例7: Start
func (ui *Gui) Start(assetPath string) {
defer ui.txDb.Close()
// Register ethereum functions
qml.RegisterTypes("Ethereum", 1, 0, []qml.TypeSpec{{
Init: func(p *Block, obj qml.Object) { p.Number = 0; p.Hash = "" },
}, {
Init: func(p *Tx, obj qml.Object) { p.Value = ""; p.Hash = ""; p.Address = "" },
}})
ethutil.Config.SetClientString(fmt.Sprintf("/Ethereal v%s", "0.1"))
ethutil.Config.Log.Infoln("[GUI] Starting GUI")
// Create a new QML engine
ui.engine = qml.NewEngine()
context := ui.engine.Context()
// Expose the eth library and the ui library to QML
context.SetVar("eth", ui.lib)
uiLib := NewUiLib(ui.engine, ui.eth, assetPath)
context.SetVar("ui", uiLib)
// Load the main QML interface
component, err := ui.engine.LoadFile(uiLib.AssetPath("qml/wallet.qml"))
if err != nil {
ethutil.Config.Log.Infoln("FATAL: asset not found: you can set an alternative asset path on on the command line using option 'asset_path'")
panic(err)
}
ui.engine.LoadFile(uiLib.AssetPath("qml/transactions.qml"))
ui.win = component.CreateWindow(nil)
// Register the ui as a block processor
//ui.eth.BlockManager.SecondaryBlockProcessor = ui
//ui.eth.TxPool.SecondaryProcessor = ui
// Add the ui as a log system so we can log directly to the UGI
ethutil.Config.Log.AddLogSystem(ui)
// Loads previous blocks
go ui.setInitialBlockChain()
go ui.readPreviousTransactions()
go ui.update()
ui.win.Show()
ui.win.Wait()
ui.eth.Stop()
}
示例8: 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
}
示例9: 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
}
示例10: 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
}
示例11: 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
}
示例12: 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()
}
示例13: 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
}
示例14: 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
}
示例15: 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()
}