ModelView Autoselection

Heads up! You've already completed this tutorial.

Mohamad_Zakwan | 2020-05-07 18:29:29 UTC | #1

Anyone manage to get the autoselection working? I've been reading the document in qt official website, but could not find a direct explanation on how to do it. I manage to get auto-selection works, but it involves creating a QRect. I don't think that's the correct way.

Hank_Ericson | 2020-06-05 01:06:24 UTC | #2

Hi Mohamad,

You can get select by replacing the


part with the following:

lastindex = self.model.index(len(self.model.todos)-1, 0)

This will first get the last index as a QModelIndex from the model itself by specifying the last row (length - 1) and column 0 and then setting that index as the current index in the todoView.

Hope this helps!

Virginia | 2020-05-07 18:32:41 UTC | #3

Thank you very much! I also had the same question and couldn't find enough information using web searches to figure it out. This is very helpful!

Over 10,000 developers have bought Create GUI Applications with Python & Qt!

To support developers in [[ countryRegion ]] I give a [[ localizedDiscount[couponCode] ]]% discount with the code [[ couponCode ]] — Enjoy!

For [[ activeDiscount.description ]] I'm giving a [[ ]]% discount with the code [[ couponCode ]] — Enjoy!

Well done, you've finished this tutorial! Mark As Complete
[[ user.completed.length ]] completed [[ user.streak+1 ]] day streak