<div dir="ltr"><div>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?</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Aug 2, 2016 at 4:02 PM, Florian Bruhin <span dir="ltr"><<a href="mailto:me@the-compiler.org" target="_blank">me@the-compiler.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">* Saeed Bakhshmand <<a href="mailto:saeedbakhshmand@gmail.com">saeedbakhshmand@gmail.com</a>> [2016-08-02 15:25:25 -0400]:<br>
<span class="">> Hello Experts,<br>
><br>
> Here is a part of my code:<br>
> b= qt.QTableView()<br>
> model = qt.QStandardItemModel()<br>
> b.setModel(model)<br>
> # ....set up of table with importing data for the items of the model<br>
><br>
> I easily can access to the indices of the manually selected (clicked) items<br>
> by sel_mode = b.selectionModel() and sel_mode.selectedIndexes().<br>
> I am wondering if I can somehow import a default set of selected items in<br>
> the table using a python command? In this way a group of per-determined<br>
> cells in the table will be selected prior to user's interactions.<br>
> b.setSelection() seems the right choice but I am not sure. Would appreciate<br>
> any hints.<br>
<br>
</span>setSelection seems to be for all items in a QRect, which doesn't sound<br>
like what you want.<br>
<br>
However, the selectionModel() has a select() method which takes a<br>
QModelIndex (plus flags) - that sounds more like what you want.<br>
<span class="HOEnZb"><font color="#888888"><br>
Florian<br>
<br>
--<br>
<a href="http://www.the-compiler.org" rel="noreferrer" target="_blank">http://www.the-compiler.org</a> | <a href="mailto:me@the-compiler.org">me@the-compiler.org</a> (Mail/XMPP)<br>
   GPG: 916E B0C8 FD55 A072 | <a href="http://the-compiler.org/pubkey.asc" rel="noreferrer" target="_blank">http://the-compiler.org/pubkey.asc</a><br>
         I love long mails! | <a href="http://email.is-not-s.ms/" rel="noreferrer" target="_blank">http://email.is-not-s.ms/</a><br>
</font></span></blockquote></div><br></div>