gpt4 book ai didi

gtk3 - 瓦拉错误 : The name `set_revealed' does not exist in the context of `Gtk.InfoBar'

转载 作者:行者123 更新时间:2023-12-01 06:30:14 27 4
gpt4 key购买 nike

我在我的用户界面中添加了一个 Gtk.InfoBar,一切看起来都不错。在 Glade 中,我可以将信息栏切换为显示,反之亦然。

关于valadoc.org文档 set_revealed 列在允许的方法中。

public void set_revealed (bool revealed)

Sets the GtkInfoBar:revealed property to revealed.

但是当我构建我的项目时,我收到了错误:名称“set_revealed”在“Gtk.InfoBar”的上下文中不存在

我做错了什么?

这是我的代码:

namespace Zeiterfassunggtk {
[GtkTemplate (ui = "/org/gnome/Zeiterfassunggtk/window.ui")]
public class Window : Gtk.ApplicationWindow {
[GtkChild]
Gtk.TreeView treeview1 = new Gtk.TreeView ();
[GtkChild]
Gtk.Button refreshbutton;
[GtkChild]
Gtk.MenuButton menubutton;
[GtkChild]
Gtk.Button menubuttonrefresh;
[GtkChild]
Gtk.Button menubuttonsave;
[GtkChild]
Gtk.Button menubuttonquit;
[GtkChild]
Gtk.InfoBar infobar1;
[GtkChild]
Gtk.Label infobar1label;

Gtk.TreeIter iter;
Gtk.ListStore liststore1 = new Gtk.ListStore (3, typeof (string), typeof (string), typeof (string));

private void setup_treeview (Gtk.TreeView treeview1) {
treeview1.set_model (liststore1);

treeview1.insert_column_with_attributes (-1, "Name", new Gtk.CellRendererText (), "text", 0, null);
treeview1.insert_column_with_attributes (-1, "Job", new Gtk.CellRendererText (), "text", 1, null);
treeview1.insert_column_with_attributes (-1, "Time", new Gtk.CellRendererText (), "text", 2, null);

liststore1.append (out iter);
liststore1.set (iter, 0, "Gerald", 1, "Job1", 2, "2018-01-01 18:23", -1);
}

void refresh () {
liststore1.append (out iter);
liststore1.set (iter, 0, "Gerald", 1, "Job1", 2, "2018-01-01 18:23", -1);
//infobar1.set_revealed (true);
}

void save () {
liststore1.append (out iter);
liststore1.set (iter, 0, "Gerald", 1, "Job2", 2, "2018-01-01 24:00", -1);
}

public Window (Gtk.Application app) {
Object (application: app);

this.maximize ();

this.setup_treeview (treeview1);

infobar1.set_revealed (false);

refreshbutton.clicked.connect (this.refresh);
menubuttonrefresh.clicked.connect (this.refresh);
menubuttonsave.clicked.connect (this.save);

menubuttonquit.clicked.connect (app.quit);

this.show_all ();
}
}
}

您可以在 github.com 找到完整代码

最佳答案

您似乎正在导入旧版本的 Gtk+。你的window.ui<requires lib="gtk+" version="3.16"/> .

set_revealed可从 [ Version ( since = "3.22.29" ) ] 获得虽然。

看来你必须更新了。

Source@valadoc.org

关于gtk3 - 瓦拉错误 : The name `set_revealed' does not exist in the context of `Gtk.InfoBar' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52098800/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com