goqt icon indicating copy to clipboard operation
goqt copied to clipboard

QFileSystemModel does not implement QAbstractItemModelInterface

Open thomasheller opened this issue 9 years ago • 2 comments

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?

thomasheller avatar Oct 01 '16 21:10 thomasheller

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.

microo8 avatar Nov 08 '16 10:11 microo8

#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)

microo8 avatar Nov 13 '16 15:11 microo8