<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><br></div><div>Hello,</div><div><br></div><div>I just joined this list and am new to PyQt (and Qt). &nbsp;I've scanned the archives, but I'm not sure even what I'm looking for to answer my question.</div><div><br></div><div>I'm looking over some C++ code, trying to rewrite it in Python. &nbsp;(My Spanish is much better than my C++!) &nbsp;I'm sub-classing and extending QDirModel and getting the following error:</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>TypeError: first argument of unbound method QDirModel.data() must be a QDirModel instance</div><div><br></div><div>The C++ methods are:</div><div><br></div><div><span class="Apple-style-span" style="color: rgb(170, 13, 145); font-family: Monaco; font-size: 10px; ">&nbsp;&nbsp; &nbsp;<span style="color: #aa0d91">virtual</span> QVariant data(<span style="color: #aa0d91">const</span> QModelIndex &amp;index, <span style="color: #aa0d91">int</span> role = Qt::DisplayRole) <span style="color: #aa0d91">const</span></span></div><div><font class="Apple-style-span" color="#AA0D91" face="Monaco" size="2"><span class="Apple-style-span" style="font-size: 10px;"><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; ">&nbsp; &nbsp; {</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; ">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #aa0d91">if</span> (role == Qt::CheckStateRole &amp;&amp; index.column() == <span style="color: #1c00cf">0</span>) {</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; ">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #aa0d91">return</span> checkstates.value(fileInfo(index).absoluteFilePath(), Qt::Unchecked);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; ">&nbsp; &nbsp; &nbsp; &nbsp; }</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; ">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #aa0d91">return</span> QDirModel::data(index, role);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; ">&nbsp; &nbsp; }</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><br></div></span></font></div><div>My translation so far looks like this:</div><div><br></div><div><br></div><div>[ ... ]</div><div>class DirModel(QtGui.QDirModel):</div><div><div><span class="Apple-tab-span" style="white-space:pre">        </span>def data(self, index, role=QtCore.Qt.DisplayRole):</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>if (role == QtCore.Qt.CheckStateRole and index.column() == 0):</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>return checkstates.value(fileInfo(index).absoluteFilePath(), QtCore.Qt.Unchecked)</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>return QtGui.QDirModel.data(index, role)</div><div>[ ... ]</div><div><br></div><div><br></div><div>Not sure how to make the first argument (index or self?) be a QDirModel instance. &nbsp;Ultimately I'm hoping for a directory tree with check boxes.</div><div><br></div></div><div>Suggestions?</div><div><br></div><div>Thanks in advance!</div><div>Scott</div><div><br></div><br><div apple-content-edited="true"> <span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><div style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><div><br></div><div><br class="khtml-block-placeholder"></div><br class="Apple-interchange-newline"></span></span></span></span></div></span> </div><br></body></html>