[PyQt] Scripted selection of items in QTableView
Saeed Bakhshmand
saeedbakhshmand at gmail.com
Tue Aug 2 21:24:25 BST 2016
Right, how can I create a QItemSelection with a desired list of indices
(e.g. [[2,4],[3,5],[1,4]]) instead of rectangular area?
On Tue, Aug 2, 2016 at 4:02 PM, Florian Bruhin <me at the-compiler.org> wrote:
> * Saeed Bakhshmand <saeedbakhshmand at gmail.com> [2016-08-02 15:25:25
> -0400]:
> > Hello Experts,
> >
> > Here is a part of my code:
> > b= qt.QTableView()
> > model = qt.QStandardItemModel()
> > b.setModel(model)
> > # ....set up of table with importing data for the items of the model
> >
> > I easily can access to the indices of the manually selected (clicked)
> items
> > by sel_mode = b.selectionModel() and sel_mode.selectedIndexes().
> > I am wondering if I can somehow import a default set of selected items in
> > the table using a python command? In this way a group of per-determined
> > cells in the table will be selected prior to user's interactions.
> > b.setSelection() seems the right choice but I am not sure. Would
> appreciate
> > any hints.
>
> setSelection seems to be for all items in a QRect, which doesn't sound
> like what you want.
>
> However, the selectionModel() has a select() method which takes a
> QModelIndex (plus flags) - that sounds more like what you want.
>
> Florian
>
> --
> http://www.the-compiler.org | me at the-compiler.org (Mail/XMPP)
> GPG: 916E B0C8 FD55 A072 | http://the-compiler.org/pubkey.asc
> I love long mails! | http://email.is-not-s.ms/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20160802/69d23925/attachment.html>
More information about the PyQt
mailing list