QLineEdit won't show Chinese characters in popup menu
-
I'm trying to set a popup menu with QLineEdit, QCheckbox.
the code is right here.
https://github.com/ThisIsClark/Qt-MultiSelectComboBoxThe env is Qt5.9.3 and win10. encode with utf-8. Using microsoft chinese default input.
But here comes a problem, Qt seems showing corectly Chinese characters with normal QLineEdits , while mSearchBar won't.
There's no character limit for this QLineEdit so my guess it's not a wrong setting issue.
How I'm I able to fix this?
Thanks -
@Puppy-Bear said in QLineEdit won't show Chinese characters in popup menu:
while mSearchBar won't
And what are the differences between mSearchBar and other QLineEdits?
-
@Puppy-Bear Possibly is associate with this bug report
https://bugreports.qt.io/browse/QTBUG-45086 -
Fix:
I tried this code & it fixed this problem ^ ^, Thanks again for response.
It seems that popup menus would get error with QLineEdit.
Rewrite eventfilter would help.bool MultiSelectComboBox::eventFilter(QObject* aObject, QEvent* aEvent) { if (aObject == mLineEdit && aEvent->type() == QEvent::MouseButtonRelease) { showPopup(); return false; } else if(aObject == mSearchBar) { if(aEvent->type() == QEvent::FocusIn) { mSearchBar->setFocus(); mSearchBar->activateWindow(); mSearchBar->grabKeyboard(); } else if(aEvent->type() == QEvent::FocusOut) { } } return QWidget::eventFilter(aObject, aEvent); //return false; }``` ![a6c6eb54-5008-4882-b5ea-48c2073090d5-image.png](https://ddgobkiprc33d.cloudfront.net/7e82b33d-b1e2-4021-854a-254fdc7bb746.png)
-
@Puppy-Bear mSearchBar->installEventFilter(this); first
-