Solved QLineEdit add QAction
-
m_PasswordLineEdit = new KeyboardLineEdit(); m_ShowPwsAction = new QAction; m_ShowPwsAction->setCheckable(true); m_ShowPwsAction->setChecked(false); m_PasswordLineEdit->addAction(m_ShowPwsAction, QLineEdit::TrailingPosition);
I want add a button in the end of lineedit.
And I use add action. It's work.
But i clicked the button lineedit also got the focusIn.
It's possible action toggled but lineedit don't get the focusIn?Qt Version 5.9.5
-
Hi.
QLineEdit is derived from QWidget. Every QWidget has set of methods regarding the focus, you can manipulate it throughout the whole UI.
I think looking into FocusPolicy might be of use but I am not certain. -
I want press in red area still got focus on click, and click on blue area only got toggled (addAction) signal.I try set ClickFocus for lineEdit for focus policy, but it's also will get the focusIn. I think is not work.
thanks for your reply.
-
@OtisLin
Then if focus policy won't do it you will have to catch the button/action click and restore focus to the line edit? -
This post is deleted! -
I think want to handle separately by QLineedit and QAction pressevent is impossible.
now I try to new QPushbutton and add to a new layout.
setlayout to QLineedit, it's look like fine. but need more test.
thanks for your reply.