examples/modelview: initial commit

This commit is contained in:
mappu 2024-11-23 20:02:41 +13:00
parent 26fc94d421
commit a0e56bf7c2
2 changed files with 39 additions and 0 deletions

1
.gitignore vendored
View File

@ -28,6 +28,7 @@ examples/windowsmanifest/windowsmanifest
examples/uidesigner/uidesigner
examples/trivialwizard6/trivialwizard6
examples/subclass/subclass
examples/modelview/modelview
examples/libraries/extras-scintillaedit/extras-scintillaedit
examples/libraries/qt-multimedia/qt-multimedia
examples/libraries/qt-network/qt-network

View File

@ -0,0 +1,38 @@
package main
import (
"fmt"
"os"
"github.com/mappu/miqt/qt"
)
func main() {
qt.NewQApplication(os.Args)
model := qt.NewQAbstractListModel()
model.OnRowCount(func(parent *qt.QModelIndex) int {
return 1000
})
model.OnData(func(idx *qt.QModelIndex, role int) *qt.QVariant {
if !idx.IsValid() {
return qt.NewQVariant()
}
switch qt.ItemDataRole(role) {
case qt.DisplayRole:
return qt.NewQVariant14(fmt.Sprintf("this is row %d", idx.Row()))
default:
return qt.NewQVariant()
}
})
v := qt.NewQListView2()
v.SetModel(model.QAbstractItemModel)
v.Show()
qt.QApplication_Exec()
}