I have a dialog in which i ask the user to enter username and password. I match them with database. If the user field is empty, i show a message box telling the user that user id is blank. I want the focus to set to user id field. How do i do that in gtkmm? Is it possible to clear the existing contents of the user 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
有帮助吗?

解决方案

Use Gtk::Widget::grab_focus() and Gtk::Entry::set_text.

l_user_id.set_text("");
l_user_id.grab_focus();
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top