therecipe / qt

Qt binding for Go (Golang) with support for Windows / macOS / Linux / FreeBSD / Android / iOS / Sailfish OS / Raspberry Pi / AsteroidOS / Ubuntu Touch / JavaScript / WebAssembly
GNU Lesser General Public License v3.0
10.5k stars 748 forks source link

How to display console window for debugging? #1215

Open smp12345 opened 3 years ago

smp12345 commented 3 years ago

Qtdeploy default compiler - H = windowsgui already hidden DOS window, won't cause some print output, should be how to operate according to the DOS window, please?I use QML, and the sample program uses the official example


package main

import (
    "fmt"
    "os"

    "github.com/therecipe/qt/core"
    "github.com/therecipe/qt/quick"
    "github.com/therecipe/qt/widgets"
)

func init() {
    ItemTemplate_QmlRegisterType2("CustomQmlTypes", 1, 0, "ItemTemplate")
}

type ItemTemplate struct {
    quick.QQuickItem

    _ string `property:"someString"`

    _ func(bool, []bool)                                                `signal:"sendBool,auto"`
    _ func(int, []int)                                                  `signal:"sendInt,auto"`
    _ func(float32)                                                     `signal:"sendFloat,auto"`
    _ func(float64, []float64)                                          `signal:"sendDouble,auto"`
    _ func(string, []string)                                            `signal:"sendString,auto"`
    _ func(error, []error)                                              `signal:"sendError,auto"`
    _ func(*core.QVariant, []*core.QVariant, map[string]*core.QVariant) `signal:"sendVariantListMap,auto"`
    _ func(*ItemTemplate, []*ItemTemplate)                              `signal:"sendItemTemplate,auto"`
    _ func(*quick.QQuickItem, []*quick.QQuickItem)                      `signal:"sendItem,auto"`
    _ func(*core.QObject, []*core.QObject)                              `signal:"sendObject,auto"`
    //...
}

func (t *ItemTemplate) sendBool(a bool, b []bool) {
    fmt.Println("sendBool:", a, b)  //This line will not output properly because there is no DOS window
}

func main() {
    core.QCoreApplication_SetAttribute(core.Qt__AA_EnableHighDpiScaling, true)
    app := widgets.NewQApplication(len(os.Args), os.Args)
    view := quick.NewQQuickView(nil)
    view.SetTitle("bridge Example")
    view.SetResizeMode(quick.QQuickView__SizeRootObjectToView)
    view.SetSource(core.NewQUrl3("qrc:/qml/main.qml", 0))
    view.Show()

    app.Exec()
}

Because there is no DOS window, this line cannot be output normally. How to add compilation options or other ways to display DOS window

func (t *ItemTemplate) sendBool(a bool, b []bool) {
    fmt.Println("sendBool:", a, b)  //This line will not output properly because there is no DOS window
}