【问题标题】:The name `find' does not exist in the context of `GLib.ListStore'“GLib.ListStore”的上下文中不存在名称“find”
【发布时间】:2020-05-24 16:29:46
【问题描述】:

我完全不知道为什么会抛出这个错误。 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)

【问题讨论】:

    标签: listbox find gtk glib vala


    【解决方案1】:

    来自您链接到的参考文档:

    [ Version ( since = "2.64" ) ]
    

    此 GIO 版本是今年才发布的:您可能使用的是不包含此功能的旧版本。

    【讨论】:

      猜你喜欢
      • 2013-10-02
      • 2015-03-01
      • 2014-04-22
      • 2017-06-17
      • 2015-09-11
      • 1970-01-01
      • 1970-01-01
      • 2022-12-18
      相关资源
      最近更新 更多