fix android deployment + examples

This commit is contained in:
therecipe 2016-12-17 21:52:41 +01:00
parent 203995b2f4
commit 8318f0c212
7 changed files with 40 additions and 29 deletions

View file

@ -512,22 +512,29 @@ import (
func main() {
widgets.NewQApplication(len(os.Args), os.Args)
//create a window
var window = widgets.NewQMainWindow(nil, 0)
window.SetWindowTitle("Hello World Example")
window.SetMinimumSize2(200, 200)
//create a layout
var layout = widgets.NewQVBoxLayout()
//add the layout to the centralWidget
var centralWidget = widgets.NewQWidget(window, 0)
centralWidget.SetLayout(layout)
//create a button and connect the clicked signal
var button = widgets.NewQPushButton2("Click me!", nil)
button.ConnectClicked(func(flag bool) {
widgets.QMessageBox_Information(nil, "OK", "You clicked me!", widgets.QMessageBox__Ok, widgets.QMessageBox__Ok)
})
//create a layout and add the button
var layout = widgets.NewQVBoxLayout()
//add the button to the layout
layout.AddWidget(button, 0, core.Qt__AlignCenter)
//create a window, add the layout and show the window
var window = widgets.NewQMainWindow(nil, 0)
window.SetWindowTitle("Hello World Example")
window.SetMinimumSize2(200, 200)
window.Layout().DestroyQObject()
window.SetLayout(layout)
//add the centralWidget to the window and show the window
window.SetCentralWidget(centralWidget)
window.Show()
widgets.QApplication_Exec()

View file

@ -526,15 +526,9 @@ func predeploy() {
utils.RunCmd(exec.Command(copyCmd, filepath.Join(depPath, "libgo_base.so"), libPath), fmt.Sprintf("copy libgo_base for %v on %v", buildTarget, runtime.GOOS))
utils.RunCmd(exec.Command(copyCmd, filepath.Join(depPath, "libgo.so"), libPath), fmt.Sprintf("copy libgo for %v on %v", buildTarget, runtime.GOOS))
var qtLibPath = filepath.Join(utils.QT_DIR(), "5.7", "android_armv7", "lib")
utils.RunCmd(exec.Command(copyCmd, filepath.Join(qtLibPath, "libQt5Widgets.so"), libPath), fmt.Sprintf("copy libQt5Widgets for %v on %v", buildTarget, runtime.GOOS))
utils.RunCmd(exec.Command(copyCmd, filepath.Join(qtLibPath, "libQt5QuickWidgets.so"), libPath), fmt.Sprintf("copy libQt5QuickWidgets for %v on %v", buildTarget, runtime.GOOS))
utils.RunCmd(exec.Command(copyCmd, filepath.Join(qtLibPath, "libQt5MultimediaWidgets.so"), libPath), fmt.Sprintf("copy libQt5MultimediaWidgets for %v on %v", buildTarget, runtime.GOOS))
utils.RunCmd(exec.Command(copyCmd, filepath.Join(qtLibPath, "libQt5Multimedia.so"), libPath), fmt.Sprintf("copy libQt5Multimedia for %v on %v", buildTarget, runtime.GOOS))
utils.RunCmd(exec.Command(copyCmd, filepath.Join(qtLibPath, "libQt5Network.so"), libPath), fmt.Sprintf("copy libQt5Network for %v on %v", buildTarget, runtime.GOOS))
utils.RunCmd(exec.Command(copyCmd, filepath.Join(qtLibPath, "libQt5AndroidExtras.so"), libPath), fmt.Sprintf("copy libQt5AndroidExtras for %v on %v", buildTarget, runtime.GOOS))
utils.RunCmd(exec.Command(copyCmd, filepath.Join(qtLibPath, "libQt5Qml.so"), libPath), fmt.Sprintf("copy libQt5Qml for %v on %v", buildTarget, runtime.GOOS))
utils.RunCmd(exec.Command(copyCmd, filepath.Join(qtLibPath, "libQt5Quick.so"), libPath), fmt.Sprintf("copy libQt5Quick for %v on %v", buildTarget, runtime.GOOS))
//trick androiddeployqt into checking dependencies from libgo_base.so
utils.RemoveAll(filepath.Join(depPath, "libgo.so"))
utils.RunCmd(exec.Command(copyCmd, filepath.Join(depPath, "libgo_base.so"), filepath.Join(depPath, "libgo.so")), "")
var out, err = json.Marshal(&struct {
Qt string `json:"qt"`
@ -702,6 +696,7 @@ func deploy() {
"--android-platform", "android-25",
"--jdk", utils.JDK_DIR(),
"--gradle",
"--verbose",
)
if utils.ExistsFile(filepath.Join(appPath, "android", appName+".keystore")) {

View file

@ -27,8 +27,10 @@ func main() {
runner.Run()
})
window.Layout().DestroyQObject()
window.SetLayout(vbox)
var centralWidget = widgets.NewQWidget(window, 0)
centralWidget.SetLayout(vbox)
window.SetCentralWidget(centralWidget)
window.Show()
widgets.QApplication_Exec()
}

View file

@ -32,8 +32,11 @@ func main() {
layout.AddWidget(newQmlWidget(), 0, 0)
var window = widgets.NewQMainWindow(nil, 0)
window.Layout().DestroyQObject()
window.SetLayout(layout)
var centralWidget = widgets.NewQWidget(window, 0)
centralWidget.SetLayout(layout)
window.SetCentralWidget(centralWidget)
window.Show()
widgets.QApplication_Exec()
@ -54,7 +57,6 @@ func newCppWidget() *widgets.QWidget {
layout.AddWidget(manipulatedFromQml, 0, 0)
var widget = widgets.NewQWidget(nil, 0)
widget.Layout().DestroyQObject()
widget.SetLayout(layout)
return widget

View file

@ -31,8 +31,10 @@ func main() {
window = widgets.NewQMainWindow(nil, 0)
windowLayout = widgets.NewQVBoxLayout()
)
window.Layout().DestroyQObject()
window.SetLayout(windowLayout)
var centralWidget = widgets.NewQWidget(window, 0)
centralWidget.SetLayout(windowLayout)
window.SetCentralWidget(centralWidget)
var addButton = widgets.NewQPushButton2("addItem", nil)
addButton.ConnectClicked(func(checked bool) {

View file

@ -102,11 +102,12 @@ func main() {
layout.AddWidget(accessGroup, 1, 1, 0)
var window = widgets.NewQMainWindow(nil, 0)
window.Layout().DestroyQObject()
window.SetLayout(layout)
window.SetWindowTitle("Line Edits")
var centralWidget = widgets.NewQWidget(window, 0)
centralWidget.SetLayout(layout)
window.SetCentralWidget(centralWidget)
window.Show()
widgets.QApplication_Exec()

View file

@ -44,8 +44,10 @@ func main() {
window.SetMinimumSize2(512, 512)
var mainLayout = widgets.NewQVBoxLayout()
window.Layout().DestroyQObject()
window.SetLayout(mainLayout)
var centralWidget = widgets.NewQWidget(window, 0)
centralWidget.SetLayout(mainLayout)
window.SetCentralWidget(centralWidget)
var scene = widgets.NewQGraphicsScene(nil)