-
Notifications
You must be signed in to change notification settings - Fork 17
Getting Started
Radhi Fadlillah edited this page Dec 2, 2019
·
8 revisions
As usual, we will create a simple "Hello World" app :
First create a project directory for your application. If you use Go modules, you can put it wherever you want. If you are not using Go modules yet, you need to put it in your GOPATH
, for example in $GOPATH/src/hello-world
. After that, create main.go
within the directory, then write following codes :
package main
import (
"os"
"github.com/go-qamel/qamel"
)
func main() {
// Create application
app := qamel.NewApplication(len(os.Args), os.Args)
app.SetApplicationDisplayName("Qamel Example")
// Create a QML viewer
view := qamel.NewViewerWithSource("qrc:/res/main.qml")
view.SetResizeMode(qamel.SizeRootObjectToView)
view.SetHeight(300)
view.SetWidth(400)
view.Show()
// Exec app
app.Exec()
}
Next create res/main.qml
within the directory then write following codes :
import QtQuick 2.12
Rectangle {
color: "cyan"
Text {
anchors.fill: parent
text: "Hello World"
font.pixelSize: 32
font.weight: Font.Bold
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
}
}
At this point, your directory should look like this :
path/to/hello-world/
├── main.go
└── res/
└── main.qml
Once finished, all you need to do is build the app and run it.