my code:
goqml.go:
package main
import (
"fmt"
"gopkg.in/qml.v1"
)
func main() {
err := qml.Run(run)
if nil != err {
fmt.Println(err)
}
}
func run() error {
engine := qml.NewEngine()
component, err := engine.LoadFile("goqml.qml")
if err != nil {
return err
}
win := component.CreateWindow(nil)
win.Show()
win.Wait()
return nil
}
goqml.qml
import QtQuick 2.0
Rectangle {
id: page
width: 320; height: 480
color: "lightgray"
Text {
id: helloText
text: "Hello world!"
y: 30
anchors.horizontalCenter: page.horizontalCenter
font.pointSize: 24; font.bold: true
}
}
Warning:
F:\GoProjects>go run goqml.go
# gopkg.in/qml.v1
In file included from F:/Qt-Android/5.7/mingw53_32/include/QtCore/QtCore:13:0,
from F:/Qt-Android/5.7/mingw53_32/include/QtQml/QtQmlDepends:3,
from F:/Qt-Android/5.7/mingw53_32/include/QtQml/QtQml:3,
from src\gopkg.in\qml.v1\cpp/capi.cpp:4,
from src\gopkg.in\qml.v1\all.cpp:2:
F:/Qt-Android/5.7/mingw53_32/include/QtCore/qendian.h:53:0:
error: "QT_HAS_BUILTIN" redefined
# define QT_HAS_BUILTIN(x)
__has_builtin(x)
^
In file included from F:/Qt-Android/5.7/mingw53_32/include/QtCore/qglobal.h:83:0,
from F:/Qt-Android/5.7/mingw53_32/include/QtCore/qcoreapplication.h:43,
from F:/Qt-Android/5.7/mingw53_32/include/QtWidgets/qapplication.h:43,
from F:/Qt-Android/5.7/mingw53_32/include/QtWidgets/QApplication:1,
from src\gopkg.in\qml.v1\cpp/capi.cpp:1,
from src\gopkg.in\qml.v1\all.cpp:2:
F:/Qt-Android/5.7/mingw53_32/include/QtCore/qcompilerdetection.h:1209:0: note: this is the location of the previous definition
#
define QT_HAS_BUILTIN(x) 0
^