GTK 滚动窗口 - 将滚动条保持在底部
我有一个使用 ScrolledWindow 的 GTK/C++ 程序。我不断将数据添加到滚动窗口内的列表中,并且我想将注意力集中在最新的项目上。 但我还想允许用户滚动数据以选择旧项目。 有办法做到这一点吗?我到处都找过了,但什么也没找到。
I have a GTK/C++ program that uses a ScrolledWindow. I keep adding data to the list within the scrolled window, and I want to keep focus on the newest item.
But I also want to allow the user to scroll through the data to select an old item.
Is there a way to do this? I've looked everywhere but can't find anything.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不太清楚你的问题是什么意思,但我认为你的意思是:当你将项目添加到列表中时,它们会添加到列表当前可见部分的下方。因此,如果您开始查看列表的底部,然后添加很多项目,那么您最终会看到列表的中间。您想要的是每次添加项目时滚动到列表底部。
如果这是正确的,那么每次添加项目时只需将窗口滚动到底部即可:
It's not quite clear to me what you mean by your question, but here's what I think you mean: when you add items to your list, they are added below the current visible portion of the list. So if you start out looking at the bottom of the list, then add a lot of items, you end up looking at the middle of the list. What you want is to scroll to the bottom of the list every time an item is added.
If that's correct, then just scroll the window to the bottom every time you add an item:
我遇到了同样的问题(在 GTKmm 上开发),
正如 @ptomato 所建议的,
但 while 循环应该在设置之前首先出现
v调整的值。 (为我工作)
I had the same issue (developing on GTKmm)
as suggested by @ptomato
but the while loop should come up first before setting
the value for vadjustment. (worked for me)