问题描述
我使用下面的代码来加载我的gui元素:
import Graphics.UI.Gtk
main = do
initGUI
- loading
builder< - builderNew
builderAddFromFile buildergui.glade
window< - builderGetObject构建器castToWindow窗口
onDestroy窗口mainQuit
widgetShowAll窗口
mainGUI
如何访问名为listStore的 ListStore
,例如我如何访问 Window $ c
$ b
-
因为castToListStore是隐藏模块的一部分,与castToWindow不同:(
listStore< - builderGetObject builder castToListStorelistStore
这取决于你想要用它做什么......
-
您始终可以使用castToTreeModel循环遍历lis中的项目tStore ....这只给出只读信息。
-
您可以忽略Haskell中liststore中的数据,只需将它连接起来即可在glade文件中由相应的小部件使用。这对于一个固定的listStore来说是有意义的(例如,内容表或者对于更改或查询没有意义的内容)。
-
您可以创建listStore在haskell中直接绑定到使用treeViewSetModel的小部件。这使您可以完全访问数据,您可以添加或删除项目并在视图中进行更改。
I'm using the following code to load my gui's elements:
import Graphics.UI.Gtk
main = do
initGUI
-- loading
builder <- builderNew
builderAddFromFile builder "gui.glade"
window <- builderGetObject builder castToWindow "window"
onDestroy window mainQuit
widgetShowAll window
mainGUI
How could I access a ListStore
named "listStore", like how I've accessed a Window
named "window"
Example:
-- doesn't compile because castToListStore is part of a hidden module, unlike castToWindow :(
listStore <- builderGetObject builder castToListStore "listStore"
It depends what you want to do with it....
You can always use castToTreeModel to iterate through the items in the listStore.... This gives read only info though.
You can just ignore the data in the listStore altogether in Haskell, and just wire it up to be used by the appropriate widget in the glade file. This makes sense for a fixed listStore (ie- table of contents or something that doesn't make sense to change or query).
You can create the listStore in haskell directly and bind it to the widget that uses it using treeViewSetModel. This gives you full access to the data, you can add or delete items and it will change in the view.
这篇关于我如何访问一个ListStore GtkBuilder的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!