문제

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