Skip to content

Commit

Permalink
examples/modelview: initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
mappu committed Nov 23, 2024
1 parent 26fc94d commit a0e56bf
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
38 changes: 38 additions & 0 deletions examples/modelview/main.go
Original file line number Diff line number Diff line change
@@ -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()
}

0 comments on commit a0e56bf

Please sign in to comment.