Properly update search bar's clear text button

This commit is contained in:
GriffinR 2025-02-13 11:40:09 -05:00
parent 5feb391a9d
commit f442f44f72

View File

@ -123,6 +123,12 @@ void MapListToolBar::applyFilter(const QString &filterText) {
const QSignalBlocker b(ui->lineEdit_filterBox);
ui->lineEdit_filterBox->setText(filterText);
// The clear button does not properly disappear when filterText is empty.
// It seems like this is because blocking the QLineEdit's signals prevents
// it from communicating the text change to QLineEditPrivate.
// We toggle the button ourselves as a workaround.
ui->lineEdit_filterBox->setClearButtonEnabled(!filterText.isEmpty());
if (m_list) {
auto model = static_cast<FilterChildrenProxyModel*>(m_list->model());
if (model) model->setFilterRegularExpression(QRegularExpression(filterText, QRegularExpression::CaseInsensitiveOption));