Listbox 名称“find';不存在于'GLib.ListStore';
我完全不知道为什么会抛出这个错误。显示此函数存在。append函数也可以工作。下面是复制它的代码:Listbox 名称“find';不存在于'GLib.ListStore';,listbox,find,gtk,glib,vala,Listbox,Find,Gtk,Glib,Vala,我完全不知道为什么会抛出这个错误。显示此函数存在。append函数也可以工作。下面是复制它的代码: class some_object : GLib.Object { public int val {get; construct;} public some_object (int val) { Object ( val: val ); } } class ExampleList : Gtk.ApplicationW
class some_object : GLib.Object {
public int val {get; construct;}
public some_object (int val) {
Object (
val: val
);
}
}
class ExampleList : Gtk.ApplicationWindow {
construct {
var dummy = new some_object(0);
var model = new GLib.ListStore (GLib.Type.from_instance (dummy));
model.append (dummy);
uint position;
model.find (dummy, out position);
// ^^^^
}
}
class MyApplication : Gtk.Application {
public MyApplication () {
Object (
application_id: "com.example.listbox"
);
}
public override void activate () {
new ExampleList (). show_all ();
}
}
public static int main (string[] args) {
return new MyApplication (). run (args);
}
要编译,我使用:
valac --pkg=gtk+-3.0 so.vala
我得到的错误是:
so.vala:18.9-18.18: error: The name `find' does not exist in the context of `GLib.ListStore'
model.find (dummy, out position);
^^^^^^^^^^
Compilation failed: 1 error(s), 0 warning(s)
从您链接到的参考文档:
[ Version ( since = "2.64" ) ]
此GIO版本仅在今年发布:您可能正在使用不包含此功能的旧版本