<div dir="ltr"><div><div>Thanks, earlier than seeing your message I managed to use connect and disconnect functions to be activated while entering On and Off states, respectively. I used<a href="https://doc.qt.io/archives/4.6/statemachine-twowaybutton.html"> this example</a> to implement state machine and added: <br>on.connect('entered()',onApplyButton_connect)<br>on.connect('exited()',onApplyButton_disconnect)<br><br></div>which ApplyButton_connect  and ApplyButton_disconnect are as following:<br><br>  def onApplyButto_connect(self):<br>   Table.selectionModel().selectionChanged.connect(cellSelected'''#call to the function that should be carried out on cell selection''')<br>    <br>  def onApplyButton_disconnect(self):<br>    Table.selectionModel().selectionChanged.disconnect(cellSelected '''#call to the function that should be carried out on cell selection''')<br><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, May 25, 2016 at 11:18 AM, David Cortesi <span dir="ltr"><<a href="mailto:davecortesi@gmail.com" target="_blank">davecortesi@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div><div><div><div><div>You want to make table items selectable when switch is On, and not selectable when Off?<br><br></div>I think the answer is in the flags() method of your table MODEL (not view).<br><br></div>You have I assume a table model based on QAbstractTableModel (<a href="http://doc.qt.io/qt-5/qabstracttablemodel.html" target="_blank">http://doc.qt.io/qt-5/qabstracttablemodel.html</a>)<br><br></div>and it has a flags() method returning the boolean OR of the flags in <a href="http://doc.qt.io/qt-5/qt.html#ItemFlag-enum" target="_blank">http://doc.qt.io/qt-5/qt.html#ItemFlag-enum</a><br><br></div>So, when the switch (button? checkbox?) state is Off, flags() must not return the Qt.ItemIsSelectable for any item.<br><br></div>When the switch changes state from On to Off, you tell the VIEW to clear the selection (<a href="http://doc.qt.io/qt-5/qabstractitemview.html#clearSelection" target="_blank">http://doc.qt.io/qt-5/qabstractitemview.html#clearSelection</a>)<br><br></div>Best of luck,<br></div>Dave Cortesi<br><br></div>
</blockquote></div><br></div>