goqt
goqt copied to clipboard
QFileSystemModel does not implement QAbstractItemModelInterface
Given the following Go code...
package main
import (
"github.com/visualfc/goqt/ui"
)
func main() {
model := ui.NewFileSystemModel()
tree := ui.NewTreeView()
tree.SetModel(model)
}
I get the following error when building:
/filetree.go:10: cannot use model (type *ui.QFileSystemModel) as type ui.QAbstractItemModelInterface in argument to tree.QAbstractItemView.SetModel:
*ui.QFileSystemModel does not implement ui.QAbstractItemModelInterface (wrong type for Index method)
have Index(string) *ui.QModelIndex
want Index(int32, int32, *ui.QModelIndex) *ui.QModelIndex
Actually, I would expect this to compile without errors.
Does QFileSystemModel not implement QAbstractItemModelInterface correctly or am I missing something obvious here?
Also ui.QStringListModel doesn't implement ui.QAbstractItemModelInterface
And it can be created only with ui.NewStringListModelFromDriver(drv ui.Driver). But in qt it has other constructors.
#40 solves the problem with QStringListModel, witch doesn't had an constructor.
also when adding the model to the view, don't pass the model pointer but the pointer to the embedded QAbstractItemModel.
tree.SetModel(&model.QAbstractItemModel)