Details
-
Bug
-
Resolution: Done
-
P3: Somewhat important
-
5.5.1, 5.6.0
-
None
-
fce83bd9f84883f93829e6ca9eacf098b018a02d
Description
#include <QApplication> #include <QTreeView> #include <QItemSelectionModel> #include <QStringListModel> #include <QTimer> #include <QDebug> int main(int argc, char** argv) { QApplication app(argc, argv); QStringListModel model{{"Monday", "Tuesday", "Wednesday", "Thursday"}}; QTreeView view; view.setModel(&model); view.show(); QTimer::singleShot(1000, &app, [&view]{ auto selm = new QItemSelectionModel(view.model(), &view); auto idx = view.model()->index(1, 0); selm->select(idx, QItemSelectionModel::Select); qDebug() << "Made selection" << idx; view.setSelectionModel(selm); // view.viewport()->update(); }); return app.exec(); }
When running the above, the widget does not immediately show the selection from the selm. Causing a repaint of the viewport, either by resizing the window for example, or explicitly in code causes the selection to be painted.
Attachments
For Gerrit Dashboard: QTBUG-50535 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
153629,4 | QAbstractItemView: trigger handlers (and redraw) when changing selection model | 5.6 | qt/qtbase | Status: MERGED | +2 | 0 |