0
我無法強制GTK通過Haskell通過帶有多列的ListStore模型在TreeView中呈現數據。我有以下代碼Gtk2hs多列TreeView與ListStore問題
addTextColumn view name =
do
col <- treeViewColumnNew
rend <- cellRendererTextNew
treeViewColumnSetTitle col name
treeViewColumnPackStart col rend True
treeViewColumnSetExpand col True
treeViewAppendColumn view col
prepareTreeView view =
do
addTextColumn view "column1"
addTextColumn view "column2"
--adding data here
然後我嘗試添加一些數據,並有問題。我試過這些:
--variant 1 (data TRow = TRow {one::String, two::String}
model <- listStoreNew ([] :: [TRow])
listStoreAppend model $ TRow { one = "Foo", two = "Boo" }
treeViewSetModel view model
--variant 2
model <- listStoreNew ([] :: [[String]])
listStoreAppend model ["foo","boo"]
treeViewSetModel view model
--variant 3
model <- listStoreNew ([] :: [(String, String)])
listStoreAppend model ("foo", "boo")
treeViewSetModel view model
但是在所有情況下,我都看到帶有列標題和插入一個空白行的表格。任何幫助將不勝感激。