[PyQt] Scripted selection of items in QTableView
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
> > 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)
> > 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
> > 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.
> 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...
More information about the PyQt