原型
gtkmm
void set_size_request(int width =-1, int height =-1);
gtk
void
gtk_widget_set_size_request (
GtkWidget* widget,
int width,
int height
)
描述
设置小部件的最小大小。
也就是说,小部件的大小请求将至少是宽度乘以高度。您可以使用此函数强制小部件比正常情况下更大。
在大多数情况下,对于顶级窗口,gtk\u window\u set\u default\u size()是比此函数更好的选择;设置默认大小仍允许用户缩小窗口。设置大小请求将强制他们离开窗口,至少与大小请求一样大。
请注意,设置任何固定大小的固有危险-主题、翻译成其他语言、不同字体和用户操作都可以更改给定小部件的适当大小。因此,基本上不可能硬编码始终正确的大小。
小部件的大小请求是小部件在正常工作和正确绘制自身时可以接受的最小大小。然而,在一些奇怪的情况下,小部件分配的空间可能小于其请求的大小,在许多情况下,小部件分配的空间可能大于其请求的空间。
如果给定方向上的大小请求为-1(未设置),则将使用小部件的“自然”大小请求。
此处设置的大小请求不包括来自属性GtkWidget:margin start、GtkWidget:margin
end、GtkWidget:margin top和GtkWidget:margin
bottom的任何边距,但它几乎包括了GtkWidget的任何子类设置的所有其他填充或边框属性。
Description
Sets the minimum size of a widget.
That is, the widget’s size request will be at least width by height. You
can use this function to force a widget to be larger than it normally
would be.
In most cases, gtk_window_set_default_size() is a better choice for
toplevel windows than this function; setting the default size will still
allow users to shrink the window. Setting the size request will force
them to leave the window at least as large as the size request.
Note the inherent danger of setting any fixed size - themes,
translations into other languages, different fonts, and user action can
all change the appropriate size for a given widget. So, it’s basically
impossible to hardcode a size that will always be correct.
The size request of a widget is the smallest size a widget can accept
while still functioning well and drawing itself correctly. However in
some strange cases a widget may be allocated less than its requested
size, and in many cases a widget may be allocated more space than it
requested.
If the size request in a given direction is -1 (unset), then the “natural” size request of the widget will be used instead.
The size request set here does not include any margin from the
properties GtkWidget:margin-start, GtkWidget:margin-end,
GtkWidget:margin-top, and GtkWidget:margin-bottom, but it does include
pretty much all other padding or border properties set by any subclass
of GtkWidget.
网站题目:Gtk调整widget部件大小size
转载来源:
http://cqcxhl.com/article/dsoijjg.html