如何设置 Gtk Box 有两个孩子

发布于 2024-09-29 08:35:30 字数 266 浏览 1 评论 0原文

我有一个 Gtk::HBox 应该只包含两个元素。然而,构造函数 new Gtk::HBox() 创建了一个包含三个元素的框,因此当我显示窗口时,有一个丑陋的空间,Gtk 希望我在其中放置第三个元素。

我以为 Gtk api 会提供一种简单的方法来设置子进程的数量,但事实并非如此。由于 Glade 允许我创建一个包含两个元素的 HBox,我想它可以完成,但现在我需要用 C++ 代码来完成。

很奇怪,我在谷歌中找不到这么简单的问题的答案,我一定错过了一些东西......有什么想法吗?

I have a Gtk::HBox which should contain two elements only. However, the constructor new Gtk::HBox() creates a box with three elements, so when I display my window, there is an ugly space where Gtk expects me to put a third element.

I thought the Gtk api would provide an easy way to set the number of children, but it doesn't. Since Glade allows me to create an HBox with two elements, I guess it can be done, but now I need to do it with c++ code.

It's very strange that I can't find answers in Google for such a simple question, I must be missing something... any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

情痴 2024-10-06 08:35:30

您应该将 expandfill 参数中的 true 传递给 Gtk::Box::pack_start()

hbox.pack_start(child, true, true);

或者调用它的 更简单的覆盖

hbox.pack_start(child);

You should pass true in the expand and fill arguments to Gtk::Box::pack_start():

hbox.pack_start(child, true, true);

Or call its simpler override:

hbox.pack_start(child);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文