QTableView default selection
-
By default, how to select the first row in QTableView with QFileSystemModel? When i use
table->selectRow(0)
it selects nothing, when i useQObject::connect(model, &QFileSystemModel::directoryLoaded, [&]{table->selectRow(0);});
it selects fourth row.
But if i usetable->selectRow(0)
in events (void keyPressEvent(QKeyEvent *event)
for example), it works ok, what is the problem? -
Hi,
Did you check the path returned by
directoryLoaded
? Is it the one you expect ?In any case, I'd use the model's index method to get the row corresponding to the loaded path.
-
It's given in parameter of the 'directoryLoaded' signal.
-
@Prince_0912
@nammidd said in QTableView default selection:@JonB This option only allows to change sorting order (from ascending to descending or vice versa), by clicking on the column header. But the sorting is done anyway, regardless of whether the option is turned on or off.