QWidget focusing widget (related to QLineEdit, HBQValidator)

52 views
Skip to first unread message

Luigi Ferraris

unread,
Aug 20, 2023, 6:18:43 AM8/20/23
to QtContribs
Hi Pritpal,
I think it's usefull to add these functions to QWidget.qth
bool QWidget::focusNextChild()
bool QWidget::focusPreviousChild()


They can be used when you need to handle input on QLineEdit and give/change focus to the next or previous widget.
Basically, they are used in QLineEdit derived class.

The mainly difference with current
QWidget *QWidget::nextInFocusChain() const
QWidget *QWidget::previousInFocusChain() const


is that they operate on the parent of the current focused widget,
to find and give focus (if found) to the next or previous widget in the parent focus chain.
While the other seems operate on widget (focused) focus chain.

The main problem is that they are defined "protect".
If this can be a problem, we can bypass adding "public" functions (I'm not a C programmer so more or less)
bool hbFocusNextChild()
{
   bool found = QWidget.focusNextChild()
   return found
}
bool hbFocusPreviousChild()
{
   bool found = QWidget.focusPreviousChild()
   return found
}

Best regards
Luigi Ferraris
Reply all
Reply to author
Forward
0 new messages