- // if there are matches, restore the textbox background to its original color
- if (m_searchApicallResults.size() > 0)
- {
- QPalette palette(ui->searchTextBox->palette());
- palette.setColor(QPalette::Base, sOriginalTextBoxBackground);
- ui->searchTextBox->setPalette(palette);
- }
-
- // select new items
- if (!searchText.isEmpty())
- {
- if (m_searchApicallResults.size() > 0)
- {
- // scroll to the first result, but don't select it
- selectApicallModelIndex(m_searchApicallResults[0], true, false);
- }
- else
- {
- // no items were found, so set the textbox background to red
- QPalette palette(ui->searchTextBox->palette());
- palette.setColor(QPalette::Base, Qt::red);
- ui->searchTextBox->setPalette(palette);
- }
- }
+ // need to briefly give the treeview focus so that it properly redraws and highlights the matching rows
+ // then return focus to the search textbox so that typed keys are not lost
+ ui->treeView->setFocus();
+ ui->searchTextBox->setFocus();