Upload
jaehoon-kim
View
705
Download
0
Embed Size (px)
Citation preview
go-qml?
- Gustavo Niemeyer
2
go-qml?
- Gustavo Niemeyer
3
go-qml?
- Gustavo Niemeyer
- Go와 QML을이용한 GUI pkg- https://github.com/go-qml/qml
- http://godoc.org/gopkg.in/qml.v1
4
go-qml?
- Gustavo Niemeyer
- Go와 QML을이용한 GUI pkg- https://github.com/go-qml/qml
- http://godoc.org/gopkg.in/qml.v1
- Ubuntu, Ubuntu Touch, Mac OS X, Windows
5
go-qml?
- Gustavo Niemeyer
- Go와 QML을이용한 GUI pkg- https://github.com/go-qml/qml
- http://godoc.org/gopkg.in/qml.v1
- Ubuntu, Ubuntu Touch, Mac OS X, Windows
- LGPL v3
6
GUI pkgs
7
GUI pkgs
- go-gtk (https://github.com/mattn/go-gtk)
- wxGo (https://github.com/JeroenD/wxGo)
- go-webkit (https://github.com/mattn/go-webkit)
- go-ui (https://github.com/visualfc/go-ui) : qt
- walk (https://github.com/lxn/walk) : only windows
- etc...
8
go-qml : requirement
- Go >= 1.2, Qt 5.x 를사용- Go 1.2 이상은 godeb로설치가능
9
install : ubuntu
- Go 설치(godeb 사용)
10
install : ubuntu
- Go 설치(godeb 사용)$ ARCH=amd64
$ wget -q https://godeb.s3.amazonaws.com/godeb-$ARCH.tar.gz
$ tar xzvf godeb-$ARCH.tar.gz
godeb
$ sudo mv godeb /usr/local/bin
$ godeb install
11
install : ubuntu
- Qt 설치
12
install : ubuntu
- Qt 설치$ sudo add-apt-repository ppa:ubuntu-sdk-team/ppa
$ sudo apt-get update
$ sudo apt-get install qtdeclarative5-dev
$ sudo apt-get install qtbase5-private-dev
$ sudo apt-get install qtdeclarative5-private-dev
$ sudo apt-get install libqt5opengl5-dev
$ sudo apt-get install qtdeclarative5-qtquick2-plugin
13
install : ubuntu
- go-qml pkg 설치
14
install : ubuntu
- go-qml pkg 설치$go get gopkg.in/qml.v1
15
install : etc
- Windows, MAC은?https://github.com/go-qml/qml#installation
16
go-qml : examples
- controls
- customtype
- gopher
- imgprovider
- modelview
- painting(-es2)
- particle
- qmlscene
- qrcpacking
- reparent
- snapweb
17
QML?
18
QML?
- Qt Framework UI를만들기위한일종의스크립트언어
19
QML?
- Qt Framework UI를만들기위한일종의스크립트언어
- QML(Qt Meta-Object Language)
20
QML?
- Qt Framework UI를만들기위한일종의스크립트언어
- QML(Qt Meta-Object Language)
- CSS와비슷
21
QML?
- Qt Framework UI를만들기위한일종의스크립트언어
- QML(Qt Meta-Object Language)
- CSS와비슷- Qt를사용하는언어들
- C++, Python, Java, Ruby, Basic, Ada ...
22
QML?
import QtQuick 2.0
Rectangle {
id: page
width: 500; height: 200
color: "lightgray"
Text {
id: helloText
text: "Hello world!"
y: 30
anchors.horizontalCenter: page.horizontalCenter
font.pointSize: 24; font.bold: true
}
}23
go-qml : basic skeletonfunc main() {
err := qml.Run(run)
...
}
24
go-qml : basic skeletonfunc main() {
err := qml.Run(run)
...
}
func run() error {
engine := qml.NewEngine()
component, err :=
engine.LoadFile(“file.qml”)
if err != nil {
return err
}
win := component.CreateWindow(nil)
win.Show()
win.Wait()
return nil
}
25
go-qml : helloworld
helloworld.qml + helloworld.go (Exam1)
26
go-qml : manipulator
- QML의객체들을 Go에서조작(Exam2)
- Qt(c++) 에서는 connect 를사용해서 signal과 slot을연결- Go에서는 Window객체의 On 을통해서 signal과 slot을연결
27
go-qml : manipulator
- Go의변수/ 타입을 QML에서사용(Exam3, 4)
- func (ctx *Context) SetVar(name string, value interface{})
- func RegisterTypes(location string, major, minor int, types []TypeSpec)type TypeSpec struct {
Init interface{}
Name string
Singleton bool
}
28
go-qml : manipulator
- 이름(변수명..)의소문자변경value.Name => value.name
value.UPPERName => value.upperName
value.UPPER => value.upper
29
go-qml : manipulator
- Setter, Getter (Exam5)
type Person struct {
Name string
}
func (p *Person) SetName(name string) {
p.Name = name
}
func (p *Person) Name() {
return p.Name
}
30
go-qml : manipulator
- Paint (Exam6)
- Go Type에 Paint 리시버를제공된다.
- OpenGL 사용- qml.RegisterType(...) 으로 QML 에제공
31
go-qml : manipulator
- 리소스패키징- genqrc : resource 파일들을 go파일로 Pack
- 설치$ go get pkg.in/qml.v1/cmd/genqrc
- 사용의편리를위해서$GOPATH/bin/ 에생성되어있는 genqrc를,
/usr/local/go/bin 으로이동
32
go-qml : manipulator
- 리소스패키징- 리소스사용(경로지정)
: some/path -> qrc:///some/path
component, err := engine.LoadFile(“qrc:///some/path”)
33
go-qml : manipulator
- 리소스패키징 (Exam7)
- genqrc 사용법genqrc [options] <subdir1> [<subdir2> …]
: subdir 에있는리소스들을 qrc.go 파일로 pack
: Go 1.4에서는 go generate 사용//go:generate genqrc code images
$ go generate
34
go-qml : manipulator
- 리소스패키징- qrc.go
개발중에는매번갱신할필요는없다.
export QRC_REPACK=1
: qrc.go를갱신하지않고변경된내용을확인가능
35
go-qml : manipulator
- QML의객체들을 Go에서조작- Go의변수/ 타입을 QML에서사용- 이름(변수명..)의대소문자변경- Setter, Getter
- Painting
- 리소스패키징
36
감사합니다.
37
references
- https://github.com/go-qml/qml
- http://gihyo.jp/admin/serial/01/ubuntu-recipe/0351
- http://godoc.org/gopkg.in/qml.v1
- http://blog.qt.digia.com/blog/category/qml_start/
- http://qt-project.org/wiki/Category:LanguageBindings/P100
- http://blog.labix.org/2014/09/26/packing-resources-into-go-qml-binaries
- http://godoc.org/gopkg.in/qml.v1/cmd/genqrc
- http://blog.golang.org/generate
- http://www.youtube.com/watch?v=FVQlMrPa7lI&list=PL8pIUS2fXtPasFbh9
3g7JaB1YEFj2bOMn
38