[prev in list] [next in list] [prev in thread] [next in thread]
List: pykde
Subject: Re: [PyQt] QSortFilterProxyModel.createIndex from within a slot
From: Zorg 421 <zorglub421 () gmail ! com>
Date: 2009-02-27 21:40:34
Message-ID: 6b546c750902271340i6c3dd20bt5e671b527930f36b () mail ! gmail ! com
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
Thanks, Mark, upon looking for a way to debug, I got another (clean and
simple) idea:
def onTableRowSelected(self, index):
if index.isValid():
>>> index0 = self.proxyModel.index(index.row(), 0) <<<
qvar = self.proxyModel.itemData(index0)
qst_ip_addr = qvar[0].toString()
self.onDraw(qst_ip_addr)
else:
print "WW: invalid index in table model!"
But your answer will for sure save me hours of pain in the next couple of
weeks.
Thanks.
On Fri, Feb 27, 2009 at 6:41 PM, Mark Summerfield <mark@qtrac.eu> wrote:
> On 2009-02-27, Zorg 421 wrote:
> > Hello PyQt users, I do not know how to use the third argument of
> > createIndex in the following code.
>
> I didn't have time to look at your code, but the third argument must be
> a QModelIndex, specifically the model index of the relevant item's
> _parent_. For top-level items this is easy: QModelIndex(); but inside
> the method using index.parent() should work fine.
>
>
> --
> Mark Summerfield, Qtrac Ltd, www.qtrac.eu
> C++, Python, Qt, PyQt - training and consultancy
> "Programming in Python 3" - ISBN 0137129297
>
>
[Attachment #5 (text/html)]
Thanks, Mark, upon looking for a way to debug, I got another (clean and simple) \
idea:<div><br></div><div><div> def onTableRowSelected(self, index):</div><div> if \
index.isValid():</div><div> >>> index0 = self.proxyModel.index(index.row(), \
0) <<<</div> <div> qvar = self.proxyModel.itemData(index0)</div><div> \
qst_ip_addr = qvar[0].toString()</div><div> self.onDraw(qst_ip_addr)</div><div> \
else:</div><div> print "WW: invalid index in table model!"</div> \
<div><br></div><div>But your answer will for sure save me hours of pain in the next couple of \
weeks.</div><div>Thanks.</div><br><div class="gmail_quote">On Fri, Feb 27, 2009 at 6:41 PM, \
Mark Summerfield <span dir="ltr"><mark@qtrac.eu></span> wrote:<br> <blockquote \
class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div \
class="Ih2E3d">On 2009-02-27, Zorg 421 wrote:<br> > Hello PyQt users, I do not know how to \
use the third argument of<br> > createIndex in the following code.<br>
<br>
</div>I didn't have time to look at your code, but the third argument must be<br>
a QModelIndex, specifically the model index of the relevant item's<br>
_parent_. For top-level items this is easy: QModelIndex(); but inside<br>
the method using index.parent() should work fine.<br>
<font color="#888888"><br>
<br>
--<br>
Mark Summerfield, Qtrac Ltd, www.qtrac.eu<br>
C++, Python, Qt, PyQt - training and consultancy<br>
"Programming in Python 3" - ISBN 0137129297<br>
<br>
</font></blockquote></div><br></div>
_______________________________________________
PyQt mailing list PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic