[PyQt] a newbie pyqt question, the pyqt book related

lotrpy lotrpy at gmail.com
Thu May 29 13:23:37 BST 2008


On Thu, May 29, 2008 at 7:58 PM, Mark Summerfield <mark at qtrac.eu> wrote:
> On 2008-05-29, lotr py wrote:
>> Hi, Sorry for my bad english and PyQt skill.
>> I am reading the book "Rapid GUI Programming with Python and Qt The
>> Definitive Guide to PyQt Programming", my question is related to
>> chap08/mymovies.pyw.
>> near the end of MainWindow.updateTable() there is
>>         if selected is not None:
>>             selected.setSelected(True)
>>             self.table.setCurrentItem(selected)
>>             self.table.scrollToItem(selected)
>> what I want to ask is, what's the mean of "selected.setSelected(True)",
>> isn't self.table.setCurrentItem(selected) enough here?
>> Thank in advance for your reply.
>
> selected is either None or the QTableItem that we want to be selected.
> So if it is not None:
>
>    selected.setSelected(True)          # selects the item
>    self.table.setCurrentItem(selected) # makes the item the current item
>    self.table.scrollToItem(selected)   # makes the item visible to the user
>
> In a QTableView it is possible to have a selected item that is not the
> current item, in other words there are two different concepts "selected
> item" and "current item".
Mark, Thanks for the quick reply, I know it's meaning now.


More information about the PyQt mailing list