mirror of
https://github.com/mappu/miqt.git
synced 2024-12-22 00:48:38 +00:00
examples/modelview: initial commit
This commit is contained in:
parent
26fc94d421
commit
a0e56bf7c2
1
.gitignore
vendored
1
.gitignore
vendored
@ -28,6 +28,7 @@ examples/windowsmanifest/windowsmanifest
|
|||||||
examples/uidesigner/uidesigner
|
examples/uidesigner/uidesigner
|
||||||
examples/trivialwizard6/trivialwizard6
|
examples/trivialwizard6/trivialwizard6
|
||||||
examples/subclass/subclass
|
examples/subclass/subclass
|
||||||
|
examples/modelview/modelview
|
||||||
examples/libraries/extras-scintillaedit/extras-scintillaedit
|
examples/libraries/extras-scintillaedit/extras-scintillaedit
|
||||||
examples/libraries/qt-multimedia/qt-multimedia
|
examples/libraries/qt-multimedia/qt-multimedia
|
||||||
examples/libraries/qt-network/qt-network
|
examples/libraries/qt-network/qt-network
|
||||||
|
38
examples/modelview/main.go
Normal file
38
examples/modelview/main.go
Normal 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()
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user