<div>Hello PyQt users, I do not know how to use the third argument of createIndex in the following code.</div><div>It&#39;s in the callback of a tree view, populated by a FilterProxyModel.</div><div><br></div><div>I want to use the value of the first column of the view when I select a line, even if I click on another column.</div>
<div><br></div><div>tree view setting for a single, whole line selection:</div><div><br></div><div><div>        self.treeView.SelectionMode = QtGui.QTreeView.SingleSelection</div><div>        self.treeView.SelectionBehavior = QtGui.QTreeView.SelectRows</div>
<div><br></div><div>My difficulty is in the onTableRowSelected method.</div><div>any help appreciated.</div><div><br></div><div><br></div><div>----</div></div><div><br></div><div><br></div><div>class MainWindow(QtGui.QMainWindow):</div>
<div>    def __init__(self, dbh):</div><div>        QtGui.QMainWindow.__init__(self)</div><div>        self.dbh = dbh</div><div>        self.createActions()</div><div>        self.createMenus()</div><div>        self.createTopIP_Table()</div>
<div>        self.proxyModel.setSourceModel(createNF_SummaryModel(self, dbh))</div><div>        self.setCentralWidget(self.proxyGroupBox)</div><div>        self.createMplFrame1()</div><div>        self.createToolBars()</div>
<div>        self.createStatusBar()</div><div>        self.createDockWindows()</div><div><br></div><div>...</div><div><br></div><div><div>    def onTableRowSelected(self, index):</div><div>        if index.isValid():</div>
<div>            print index.row(), index.column()</div><div>            #index_ip = self.proxyModel.createIndex(index.row(), 0, self.proxyModel) </div><div>            index_ip = self.proxyModel.createIndex(index.row(), 0, 0) &lt;----------- ????</div>
<div>            qvar = self.proxyModel.itemData(index_ip)</div><div>            qst_ip_addr = qvar[0].toString()</div><div>            print qst_ip_addr</div><div>            self.onDraw(qst_ip_addr)</div><div>        else:</div>
<div>            print &quot;WW: invalid index in table model!&quot;</div><div><br></div><div>    def createTopIP_Table(self):</div><div>        self.proxyModel = QtGui.QSortFilterProxyModel()</div><div>        self.proxyModel.setDynamicSortFilter(True)</div>
<div>        self.selectionModel = QtGui.QItemSelectionModel(self.proxyModel)</div><div>        self.treeView = QtGui.QTreeView()</div><div>        self.treeView.setModel(self.proxyModel)</div><div>        self.treeView.setSelectionModel(self.selectionModel)</div>
<div>        self.treeView.SelectionMode = QtGui.QTreeView.SingleSelection</div><div>        self.treeView.SelectionBehavior = QtGui.QTreeView.SelectRows</div><div>        self.connect(self.treeView.selectionModel(), QtCore.SIGNAL(&quot;currentRowChanged(QModelIndex, QModelIndex)&quot;), </div>
<div>self.onTableRowSelected)</div><div>        self.treeView.setSortingEnabled(True)</div><div>        self.treeView.sortByColumn(2, QtCore.Qt.DescendingOrder)</div><div>        self.treeView.setRootIsDecorated(False)</div>
<div>        self.treeView.setAlternatingRowColors(True)</div><div>        self.proxyGroupBox = QtGui.QGroupBox(&quot;blah blah&quot;)</div><div>        proxyLayout = QtGui.QGridLayout()</div><div>        proxyLayout.addWidget(self.treeView, 0, 0, 1, 7)</div>
<div>        self.proxyGroupBox.setLayout(proxyLayout)</div><div><br></div><div><div>def addIP(model, ...):</div><div>    model.insertRow(0)</div><div>    model.setData(model.index(0, 0), QtCore.QVariant(ip))</div><div>    model.setData(model.index(0, 3), QtCore.QVariant(pkt_in))</div>
<div>    model.setData(model.index(0, 4), QtCore.QVariant(pkt_out))</div><div>    model.setData(model.index(0, 5), QtCore.QVariant(byte_in))</div><div>    model.setData(model.index(0, 6), QtCore.QVariant(byte_out))</div><div>
<br></div><div>def createNF_SummaryModel(parent, dbh):</div><div>    model = QtGui.QStandardItemModel(0, 7, parent)</div><div>    model.setHeaderData(0, QtCore.Qt.Horizontal, QtCore.QVariant(&quot;IP Address&quot;))</div>
<div>    model.setHeaderData(1, QtCore.Qt.Horizontal, QtCore.QVariant(&quot;flows/sec in&quot;))</div><div>    model.setHeaderData(2, QtCore.Qt.Horizontal, QtCore.QVariant(&quot;flows/sec out&quot;))</div><div>    model.setHeaderData(3, QtCore.Qt.Horizontal, QtCore.QVariant(&quot;pkts/sec in&quot;))</div>
<div>    model.setHeaderData(4, QtCore.Qt.Horizontal, QtCore.QVariant(&quot;pkts/sec out&quot;))</div><div>    model.setHeaderData(5, QtCore.Qt.Horizontal, QtCore.QVariant(&quot;bytes/sec in&quot;))</div><div>    model.setHeaderData(6, QtCore.Qt.Horizontal, QtCore.QVariant(&quot;bytes/sec out&quot;))</div>
<div>    scale = 1.0/300.0</div><div>    req = &quot;SELECT blah blah&quot;</div><div>    cdb = dbh.cursor()</div><div>    cdb.execute(req)</div><div>    res = cdb.fetchone()</div><div>    req = &quot;&quot;&quot;SELECT blah blah&quot;&quot;&quot; % res[0]</div>
<div>    cdb.execute(req)</div><div>    res = cdb.fetchall()</div><div>    for (....) in res:</div><div>        addIP(model, ...)</div><div>    cdb.close()</div><div>    return model</div></div></div>