gpt4 book ai didi

Gtk 小部件最小和最大宽度/高度,可调整为 true

转载 作者:行者123 更新时间:2023-12-04 22:50:12 28 4
gpt4 key购买 nike

我是 gtk 的新手并使用 gtkmm-3.0,我正在努力为 gtk 小部件设置最小宽度和高度。我使用了 set_size_request 方法,但是当我调整父容器的大小时,小部件仍然超过其最小/最大大小。

我的代码看起来像

foo::foo()
{
set_default_size(400,400); // set default size for window
add(grid_layout);

menu_bar.append(file);
menu_bar.append(edit);
menu_bar.append(project);
menu_bar.append(settings);
menu_bar.append(help);


right_panel_notebook.insert_page(right_btn, "Page1", Gtk::POS_RIGHT);
right_panel_notebook.insert_page(notebook_btn, "Page2", Gtk::POS_RIGHT);
right_panel_notebook.set_size_request(400,300); // setting size for a Notebook widget


design_paned.set_vexpand(true);
design_paned.add1(btn);
design_paned.add2(right_panel_notebook);


grid_layout.set_row_homogeneous(false);
grid_layout.set_column_homogeneous(true);
grid_layout.attach_next_to(menu_bar, Gtk::POS_RIGHT, 1,1);
grid_layout.attach_next_to(design_paned, Gtk::POS_BOTTOM, 1,1);

show_all();
}

那么,有什么方法可以限制小部件的最小/最大大小,并将其调整为 true。

最佳答案

不确定这是否是您想要的,但查看您的代码,在 GtkPaned 内的 GtkNotebook 上调用了 set_size_request,因此:

GtkPaned child 有两个属性, resize shrink :

Each child has two options that can be set, resize and shrink . If resize is true, then when the GtkPaned is resized, that child will expand or shrink along with the paned widget. If shrink is true, then that child can be made smaller than its requisition by the user. Setting shrink to FALSE allows the application to set a minimum size. If resize is false for both children, then this is treated as if resize is true for both children



shrink设置为 TRUE那么笔记本可以比您要求的 400x300 尺寸小。

要设置这些属性,请使用 GtkPanned pack1 pack2 方法而不是 add1add2 .

关于Gtk 小部件最小和最大宽度/高度,可调整为 true,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44976522/

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