Oops...sorry I have some updates...Forget about my solution above - calling the base class function first before the overriden one.
I realized it's safer to just set something, somewhat like simulating a normal behavior and let the base class perform the default behavior. So to summarize the behavior I need to is to wrap to the first item if user has pressed the down key while on the last item and vice versa. I somewhat implemented correctly this behavior but the other way around, my code failed.
Here is how I implmented wrapping from last -> first item while down key is pressed on the last item,
// if current row is equal to last item in the list
listWidget->setCurrentRow(-1); // is there other non hacky way to do this? This has worked by the way
// simulating a normal behavior, use row -1 so that next row is 0 which is the first item
// call base class function here, this is expected to go to the next row which is 0
// if current row is equal to last item in the list
listWidget->setCurrentRow(-1); // is there other non hacky way to do this? This has worked by the way
// simulating a normal behavior, use row -1 so that next row is 0 which is the first item
// call base class function here, this is expected to go to the next row which is 0
To copy to clipboard, switch view to plain text mode
For the other way around, first -> last item wrap,
// if current row is equal to the first row in the list
listWidget->setCurrentRow(listWidget->count()); // simulating a normal behavior, setting the row = count, next row should be count -1 which is the last item
// but this didn't work, how should i do this?
// call base class function here, this should go to the next row count-1 but this didn't work
// if current row is equal to the first row in the list
listWidget->setCurrentRow(listWidget->count()); // simulating a normal behavior, setting the row = count, next row should be count -1 which is the last item
// but this didn't work, how should i do this?
// call base class function here, this should go to the next row count-1 but this didn't work
To copy to clipboard, switch view to plain text mode
Please help.
Bookmarks