Hiding the cursor on QLineEdit
-
Pretty much the title. I have a QLineEdit and I want whenever the user clicks away on something else to stop the focus on the QLineEdit. If that's not possible then if you guys have any idea on how to completely remove the cursor in the first place that would also work.
Thanks! -
@Pl45m4 oh yeah whenever I click on a different widget it disappears that's a brain fart on my end haha. But it doesn't work when clicking on a QFrame.. any way to change that?
BTW, if it helps in general:
Windows 10, QT 6.5, default QLineEdit. -
Pretty much the title. I have a QLineEdit and I want whenever the user clicks away on something else to stop the focus on the QLineEdit. If that's not possible then if you guys have any idea on how to completely remove the cursor in the first place that would also work.
Thanks!@Jonikles said in Hiding the cursor on QLineEdit:
I have a QLineEdit and I want whenever the user clicks away on something else to stop the focus on the QLineEdit.
When you "click away to something else" that should remove the focus on the
QLineEdit, and stop showing the cursor. -
@Jonikles said in Hiding the cursor on QLineEdit:
I have a QLineEdit and I want whenever the user clicks away on something else to stop the focus on the QLineEdit.
When you "click away to something else" that should remove the focus on the
QLineEdit, and stop showing the cursor.@JonB like automatically? if that's what you're saying then that is not what's happening for me. It's like this:
Until you start editing - no focus obviously, but once you do it never goes away unless I focus onto a different QEditLine but that's no solution. -
@JonB like automatically? if that's what you're saying then that is not what's happening for me. It's like this:
Until you start editing - no focus obviously, but once you do it never goes away unless I focus onto a different QEditLine but that's no solution. -
@Jonikles said in Hiding the cursor on QLineEdit:
I have a QLineEdit and I want whenever the user clicks away on something else to stop the focus on the QLineEdit.
When you "click away to something else" that should remove the focus on the
QLineEdit, and stop showing the cursor.@JonB said in Hiding the cursor on QLineEdit:
When you "click away to something else" that should remove the focus on the QLineEdit, and stop showing the cursor.
Depends on what/where clicking elsewhere is, I guess.
If you ( @Jonikles ) click/focus another widget or window, the cursor should definitely disappear.
Can you confirm that?!What OS are you on? Which Qt version? Are we dealing with a default
QLineEditor any re-implementation or subclass?But this sounds so weird, that it is too obvious to be a bug that stayed in for a longer time, no matter what Qt version.
-
@JonB said in Hiding the cursor on QLineEdit:
When you "click away to something else" that should remove the focus on the QLineEdit, and stop showing the cursor.
Depends on what/where clicking elsewhere is, I guess.
If you ( @Jonikles ) click/focus another widget or window, the cursor should definitely disappear.
Can you confirm that?!What OS are you on? Which Qt version? Are we dealing with a default
QLineEditor any re-implementation or subclass?But this sounds so weird, that it is too obvious to be a bug that stayed in for a longer time, no matter what Qt version.
-
@Pl45m4 oh yeah whenever I click on a different widget it disappears that's a brain fart on my end haha. But it doesn't work when clicking on a QFrame.. any way to change that?
BTW, if it helps in general:
Windows 10, QT 6.5, default QLineEdit.@Jonikles said in Hiding the cursor on QLineEdit:
But it doesn't work when clicking on a QFrame
Clicking on a
QFrameor plainQWidgetdoesn't direct the focus to them per default. It triggers MouseClick / -ReleaseEvents, but the focus stays atQLineEdit, therefore the cursor is staying visible. Same for any other widget, where you can select something. SelectedQListWidgetItemsstay selected, when clicking somewhere on an emptyQWidgetspace (QFrameis also aQWidget).To work around that, try what @mpergand suggested. Install an eventFilter and move the focus where you want it to be, when your
QLineEdithas focus and yourQFrameis clicked.[Edit: @mpergand 's new solution works even better ;-) ]
-
@Pl45m4 oh yeah whenever I click on a different widget it disappears that's a brain fart on my end haha. But it doesn't work when clicking on a QFrame.. any way to change that?
BTW, if it helps in general:
Windows 10, QT 6.5, default QLineEdit. -
@Jonikles said in Hiding the cursor on QLineEdit:
But it doesn't work when clicking on a QFrame.. any way to change that?
call :
QFrame::setFocusPolicy(Qt::ClickFocus) -
J Jonikles has marked this topic as solved on
-
J Jonikles has marked this topic as unsolved on
-
J Jonikles has marked this topic as solved on