|
42 | 42 | //
|
43 | 43 | // The following logic demonstrates loading a QML file into a window:
|
44 | 44 | //
|
45 |
| -// func main() { |
46 |
| -// err := qml.Run(run) |
47 |
| -// ... |
48 |
| -// } |
49 |
| -// |
50 |
| -// func run() error { |
51 |
| -// engine := qml.NewEngine() |
52 |
| -// component, err := engine.LoadFile("file.qml") |
53 |
| -// if err != nil { |
54 |
| -// return err |
55 |
| -// } |
56 |
| -// win := component.CreateWindow(nil) |
57 |
| -// win.Show() |
58 |
| -// win.Wait() |
59 |
| -// return nil |
60 |
| -// } |
| 45 | +// func main() { |
| 46 | +// err := qml.Run(run) |
| 47 | +// ... |
| 48 | +// } |
| 49 | +// |
| 50 | +// func run() error { |
| 51 | +// engine := qml.NewEngine() |
| 52 | +// component, err := engine.LoadFile("file.qml") |
| 53 | +// if err != nil { |
| 54 | +// return err |
| 55 | +// } |
| 56 | +// win := component.CreateWindow(nil) |
| 57 | +// win.Show() |
| 58 | +// win.Wait() |
| 59 | +// return nil |
| 60 | +// } |
61 | 61 | //
|
62 | 62 | // Handling QML objects in Go
|
63 | 63 | //
|
|
71 | 71 | //
|
72 | 72 | // win := component.CreateWindow(nil)
|
73 | 73 | // win.On("visibleChanged", func(visible bool) {
|
74 |
| -// if (visible) { |
75 |
| -// fmt.Println("Width:", win.Int("width")) |
76 |
| -// } |
| 74 | +// if (visible) { |
| 75 | +// fmt.Println("Width:", win.Int("width")) |
| 76 | +// } |
77 | 77 | // })
|
78 | 78 | //
|
79 | 79 | // Information about the methods, properties, and signals that are available for QML
|
|
111 | 111 | // the following example demonstrates:
|
112 | 112 | //
|
113 | 113 | // qml.RegisterTypes("GoExtensions", 1, 0, []qml.TypeSpec{{
|
114 |
| -// Init: func(p *Person, obj qml.Object) { p.Name = "<none>" }, |
| 114 | +// Init: func(p *Person, obj qml.Object) { p.Name = "<none>" }, |
115 | 115 | // }})
|
116 | 116 | //
|
117 | 117 | // With this logic in place, QML code can create new instances of Person by itself:
|
|
150 | 150 | // For example:
|
151 | 151 | //
|
152 | 152 | // type Person struct {
|
153 |
| -// Name string |
| 153 | +// Name string |
154 | 154 | // }
|
155 | 155 | //
|
156 | 156 | // func (p *Person) SetName(name string) {
|
157 |
| -// fmt.Println("Old name is", p.Name) |
158 |
| -// p.Name = name |
159 |
| -// fmt.Println("New name is", p.Name) |
| 157 | +// fmt.Println("Old name is", p.Name) |
| 158 | +// p.Name = name |
| 159 | +// fmt.Println("New name is", p.Name) |
160 | 160 | // }
|
161 | 161 | //
|
162 | 162 | // In the example above, whenever QML code attempts to update the Person.Name field
|
|
177 | 177 | // a Paint method such as:
|
178 | 178 | //
|
179 | 179 | // func (p *Person) Paint(painter *qml.Painter) {
|
180 |
| -// // ... OpenGL calls with the gopkg.in/qml.v1/gl/<VERSION> package ... |
| 180 | +// // ... OpenGL calls with the gopkg.in/qml.v1/gl/<VERSION> package ... |
181 | 181 | // }
|
182 | 182 | //
|
183 | 183 | // A simple example is available at:
|
|
0 commit comments