Hello Gophers,
that’s a real mystery to me. I’m using the github.com/therecipe/qt-Package and I am connecting a push button with an anonymous function, to select a file or directory and set the selected path to a QLineEdit. And it does work like this way:
import (
"github.com/therecipe/qt/core"
"github.com/therecipe/qt/uitools"
"github.com/therecipe/qt/widgets"
)
//...
var (
ui_formConfigs map[string](*widgets.QLineEdit)
ui_pushButtons map[string](*widgets.QPushButton)
)
ui_formConfigs = make(map[string]*widgets.QLineEdit)
ui_pushButtons = make(map[string]*widgets.QPushButton)
//...
ui_formConfigs["InputDirectory"] = widgets.NewQLineEditFromPointer(widget.FindChild("inputDirectoryLineEdit", core.Qt__FindChildrenRecursively).Pointer())
ui_formConfigs["InputDirectory"].SetText(config.Paths.InputDirectory)
ui_pushButtons["pushButtonSelectInputDirectory"] = widgets.NewQPushButtonFromPointer(widget.FindChild("pushButtonSelectInputDirectory", core.Qt__FindChildrenRecursively).Pointer())
ui_pushButtons["pushButtonSelectInputDirectory"].ConnectClicked(func(checked bool) {
//ui_formConfigs["InputDirectory"].SetText((*widgets.QFileDialog).GetOpenFileName(nil, "Some title", "./", "*", "*", widgets.QFileDialog__ShowDirsOnly))
ui_formConfigs["InputDirectory"].SetText((*widgets.QFileDialog).GetOpenFileName(nil, nil, "Some title", "./", "*", "*", widgets.QFileDialog__ShowDirsOnly))
})
However,
(*widgets.QFileDialog).GetOpenFileName(nil, nil, "Some Title", "./", "*", "*", widgets.QFileDialog__ShowDirsOnly)
is strange (for me). Because compiler had advised me before:
And now please have a look at the definition in src/github.com/therecipe/qt/widgets/widgets.go:
func (ptr *QFileDialog) GetOpenFileName(parent QWidget_ITF, caption string, dir string, filter string, selectedFilter string, options QFileDialog__Option) string {...}
I was counting 6 arguments, but compiler wants 7!!! What’s wrong? How is that possible?
Thanks in advance!