[Interest] QTableView::moveCursor and scrolling to end
Nurmi J-P
jpnurmi at digia.com
Tue May 14 23:17:44 CEST 2013
On May 14, 2013, at 9:17 AM, Mojmír Svoboda <Mojmir.Svoboda at warhorsestudios.cz> wrote:
> Hello,
>
> my problem is simple: when an user press ctrl+end to scroll to the end
> of the table then there is an implicit horizontal scroll to the right.
> My users requested few times already to disable that behaviour.
>
> I subclassed QTableView as i did not found any other way (sorry if i
> missed something obvious), but as soon as i tried to override moveCursor
> i started to fail because of internals like d->visualCursor or d->spans.
> Some of them seem trivial to bypass (like d->root, d->visualRow etc)
> some of them not (d->spans).
>
Hi,
Perhaps you could simply return the desired sibling for the index returned by the base class implementation. Consider the following pseudo-example:
QModelIndex MyTableView::moveCursor(action, modifiers)
{
QModelIndex index = QTableView::moveCursor(action, modifiers);
if (action == MoveEnd && modifiers & Control)
index = index.sibling(index.row(), currentIndex().column()); // keep the column intact
return index;
}
--
J-P Nurmi
More information about the Interest
mailing list