简体   繁体   English

GTK:结构 gtk::Box 存在方法 append,但不满足其特征边界

[英]GTK: the method append exists for struct gtk::Box, but its trait bounds were not satisfied

I am brand new to GTK with Rust as well as being new to the Rust language itself and I am putting together a small demo app as practice and at one point I created a content widget which is a Box class I believe.我是 GTK 和 Rust 的新手,也是 Rust 语言本身的新手,我正在整理一个小型演示应用程序作为练习,有一次我创建了一个content小部件,我相信它是一个Box class。

let content = Box::new(Orientation: Vertical, 0);
content.append(&label);
content.append(&button);

I appended the widgets into my box and then on the child property of the builder I passed in the box widget, in other words content like so:我将小部件附加到我的框中,然后附加到我在框小部件中传递的构建器的子属性,换句话说, content如下:

let window = ApplicationWindow::builder()
     .title("UI Demo")
     .application(_app)
     .child(&content)
     .build();

But with the above code, I am getting an error on append() saying:但是使用上面的代码,我在append()上收到错误消息:

GTK: the method append exists for struct gtk::Box, but its trait bounds were not satisfied. GTK:结构 gtk::Box 存在方法 append,但不满足其特征边界。 The following trait bounds were not satisfied: gtk::Box: IsA which is required by gtk::Box: gtk::prelude::UnixFDListExtManual gtk::Box IsA which is required by gtk::Box...不满足以下特征界限: gtk::Box: gtk::Box 所需的 IsA: gtk::prelude::UnixFDListExtManual gtk::Box IsA gtk::Box 所需的...

And it just goes on like this.它就这样继续下去。

The error is due to you using the gtk4 method append on Box while having gtk (the gtk3 bindings) in your dependencies.该错误是由于您在Box上使用gtk4方法append而在您的依赖项中具有gtk (gtk3 绑定)。 If you have gtk4 available on your system you can drop in replace your gtk dependency to:如果您的系统上有可用的 gtk4,您可以将gtk依赖替换为:

gtk = { version = "0.5.5", package = "gtk4" }

in your Cargo.toml在你的Cargo.toml

If you're limited to gtk3 you have to use the gtk3 api of Box .如果您仅限于 gtk3,则必须使用Box的 gtk3 api

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 “我的第一次生锈”:枚举 `Option&lt;&amp;mut...&gt;` 存在方法 `unwrap_or_default`,但不满足其特征界限 - "my first rust": the method `unwrap_or_default` exists for enum `Option<&mut ...>`, but its trait bounds were not satisfied rust 柴油方法“过滤器”存在于模式表,但其特征界限不满足? - rust diesel method `filter` exists for schema table, but its trait bounds were not satisfied? 错误:类型 `u8` 的方法`set_bit` 存在,但不满足其特征界限(适用于 usize?) - error: the method `set_bit` exists for type `u8`, but its trait bounds were not satisfied (works for usize?) 方法存在但不满足以下特征边界(泛型) - Method exists but the following trait bounds were not satisfied (generics) 扩展失败类型的结果时,为什么会得到“该方法存在,但以下特征范围不满足”的信息? - Why do I get “the method exists but the following trait bounds were not satisfied” when extending Result for failure types? rust tokio trait bounds 不满足前向方法 - rust tokio trait bounds were not satisfied on forward method 当“方法存在但特质界限不满足”时,这意味着什么? - What does it mean when “method exists but trait bounds not satisfied”? 方法for_each存在,但使用StreamDeckSocket时无法满足特征范围 - The method for_each exists but trait bounds not satisfied when using StreamDeckSocket 当使用ReadBytesExt从字节片中读取整数时,为什么会出现错误“特征边界未得到满足”? - Why do I get the error “trait bounds were not satisfied” when using ReadBytesExt to read an integer from a slice of bytes? 在 GTK4 中制作一个可点击的框 - Making a clickable box in GTK4
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM