Qt: уход фокуса из виджета возможен только с приходом фокуса в другой?



My complex GUI consists of many native and custom widgets. Most of them has no focus at all (i don't need it: for example, some display-only widgets that doesn't need user's input).

Sometimes QLineEdit appears on the screen when GUI want user to input some string (imagine window's Explorer after pressing F2 having some file selected (rename).

I want user to be able to close this QLineEdit as many ways as possible: pressing Enter, ESC, clicking outside the QLineEdit.

QLineEdit sends editingFinished() signal in some circumstances (press Enter, click on another widget); Also i can make new class derived from QLineEdit that sends editingFinished() signal when focusOutEvent(QFocusEvent *) occurs. In that class i can catch ESC key and send the editingFinished(). The only problem is that QLineEdit loses focus only if some another widget takes the focus. So if you click to a widget that doesn't care about focus, the QLineEdit stay having focus and doesn't send the editingFinished() signal.


считаю плохим дизайном, когда неясно - ввелось ли значение при потере фокуса или нет

x905 ★★★★★ ()
Вы не можете добавлять комментарии в эту тему. Тема перемещена в архив.