【问题标题】:How do i use set_focus_child to set focus to a text entry in gtkmm?如何使用 set_focus_child 将焦点设置到 gtkmm 中的文本条目?
【发布时间】:2013-09-03 11:36:20
【问题描述】:

我有一个对话框,要求用户输入用户名和密码。我将它们与数据库匹配。如果用户字段为空,我会显示一个消息框,告诉用户用户 ID 为空。我希望将焦点设置为用户 ID 字段。我如何在 gtkmm 中做到这一点?是否可以清除用户id的现有内容?

l_user_id=m_user_id->get_text();
l_password=m_password->get_text();

if(l_user_id=="")
  throw_dialog("Empty Field","Please enter a user name");
  // i want to clear the user id field
  // i want to set focus to user id field

【问题讨论】:

  • 我可以使用 set_text() 清除用户 id 字段的内容。

标签: gtkmm


【解决方案1】:

使用Gtk::Widget::grab_focus()Gtk::Entry::set_text

l_user_id.set_text("");
l_user_id.grab_focus();

【讨论】:

  • m_user_id->grab_focus();非常感谢马克。
猜你喜欢
  • 2015-09-19
  • 1970-01-01
  • 2015-10-11
  • 2020-06-04
  • 2019-07-04
  • 2014-04-24
  • 2011-11-23
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多