GHashTableIter 将 GtkSpinButton 设置为可调整
我需要将我的 GHashTable
- SpinButtons
的组件更改为其 Adjustments
我认为这可以解决问题,但显然事实并非如此。 Gdb 没有多大帮助(step
只是跳过)
GHashTableIter adjusthashtable;
gpointer key, value;
g_hash_table_iter_init (&adjusthashtable, widgetbuffer);
while (g_hash_table_iter_next (&adjusthashtable, &key, &value))
{
if(strcmp(G_OBJECT_TYPE_NAME(value),"GtkSpinButton") == 0){
value = gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(value));
}
}
I need to alter components of my GHashTable
- SpinButtons
- to their Adjustments
I assumed this would do the trick, but apparently it doesn't. Gdb doesn't help much (step
just steps over)
GHashTableIter adjusthashtable;
gpointer key, value;
g_hash_table_iter_init (&adjusthashtable, widgetbuffer);
while (g_hash_table_iter_next (&adjusthashtable, &key, &value))
{
if(strcmp(G_OBJECT_TYPE_NAME(value),"GtkSpinButton") == 0){
value = gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(value));
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要使用旧键将新值重新插入到哈希表中。唯一的问题是这可能会使您的迭代器无效,因此您可能需要重新初始化它。您还可以比现在更有效地检查小部件是否是旋转按钮,因此内部循环将变为:
You need to re-insert the new value into the hashtable with the old key. The only problem is that that might invalidate your iterator, so you might need to reinitialize it. You can also check if the widget is a spin button much more efficiently than you are doing now, so the inner loop would become: