如何在 C 中禁用 GtkTextView 的编辑?

发布于 2024-08-30 09:26:34 字数 239 浏览 8 评论 0原文

我尝试了这个,它生成了一个 TextView 窗口:

http://zetcode.com/tutorials/gtktutorial/ gtktextview/

但我不希望它可编辑。

顺便问一下,当文本溢出时如何显示滚动条?

I tried this one and it generates a TextView window:

http://zetcode.com/tutorials/gtktutorial/gtktextview/

But I don't want it to be editable.

BTW, how can I show the scroll bar when the text overflows?

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

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

发布评论

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

评论(1

嘦怹 2024-09-06 09:26:34

检查 http://library.gnome.org/devel/gtk/stable/GtkTextView .html

有一个gtk_text_view_set_editable函数。

您可以通过将滚动条添加到 GtkScrolledWindow 来向小部件添加滚动条。例如:

GtkWidget* scrolled = gtk_scrolled_window_new(NULL, NULL);
gtk_container_add (GTK_CONTAINER (scrolled), view);

然后不要用视图调用 pack_start,而是用滚动调用它。

对于居中,GtkScrolledWindow 不是顶级窗口,因此它的位置取决于父容器(示例中的 VBox)。有用于填充等的 pack_start 参数,这可能会得到你想要的。

Check http://library.gnome.org/devel/gtk/stable/GtkTextView.html:

There's a gtk_text_view_set_editable function.

You can add scrollbars to widgets by adding them to a GtkScrolledWindow. Eg:

GtkWidget* scrolled = gtk_scrolled_window_new(NULL, NULL);
gtk_container_add (GTK_CONTAINER (scrolled), view);

And then instead of calling pack_start with view, call it with scrolled.

For centering, a GtkScrolledWindow isn't a top-level window so its position depends on the parent container (a VBox in the example). There are parameters of pack_start for padding etc which might get what you want.

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