[Interest] selectionChanged on remove
private at bernhard-lindner.de
Mon Jun 12 21:36:41 CEST 2017
Could someone please explain me some odd behavior of Qt 5.7 models and
the corresponding selection models?
Please start the "Editable Tree Model" example. Remove all rows except
two. Select the first row. Then set a breakpoint to the following line
of function MainWindow::updateActions() in file mainwindow.cpp:
int row = view->selectionModel()->currentIndex().row();
Then remove the first row.
When I do this, I can see that the MainWindow::updateActions() function
is called two times. The first time it is called by the signal/slot
connection from the selectionChanged signal; the second time it is
called from MainWindow::removeColumn() by the application.
The problem: In the first call, the new selected row is 1. This is fatal
because after removing the first of two rows there is no row with index
The second call to MainWindow::updateActions(), done by the application,
fixes that problem but I wonder why it is necessary.
In my application I have the same behavior except that I totally rely on
the seletionChanged() signal... which is why my application crashes.
Is that actually desired behavior?
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 819 bytes
Desc: OpenPGP digital signature
More information about the Interest