名称“find”在“GLib.ListStore”的上下文中不存在
The name `find' does not exist in the context of `GLib.ListStore'
我完全不知道为什么会抛出这个错误。 valadoc 说明这个函数存在。追加功能也有效。这是重现它的代码:
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)
从参考文档中您 link 到:
[ Version ( since = "2.64" ) ]
这个GIO版本是今年才发布的:很可能您使用的是不包含此功能的旧版本。
我完全不知道为什么会抛出这个错误。 valadoc 说明这个函数存在。追加功能也有效。这是重现它的代码:
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)
从参考文档中您 link 到:
[ Version ( since = "2.64" ) ]
这个GIO版本是今年才发布的:很可能您使用的是不包含此功能的旧版本。