<div id="__MailbirdStyleContent" style="font-size: 12pt;font-family: Candara;color: #000000"><span style="color: #366092">
Hi Kyle. Thanks for the help. Each time I post to this group, I learn a little more.</span><div><span style="color: #366092"><br></span></div><div><b style="font-size: 12pt;line-height: 1.5"><span style="color: #366092">[1]</span></b></div><div><span style="color: #366092">The <font face="Consolas">x.py</font> that you sent back passes the model tester when I run it as well. I suspect the reason that the version I posted crashed was because I tried to instantiate the dialog widget (<font face="Courier New">Dlg</font>) from the tester function. The tester function doesn't create a <font face="Courier New">QApplication</font>, so it was foolish of me to think it could create a widget there.</span></div><div><span style="color: #366092"><br></span></div><div><span style="color: #366092">Your version just removed the <font face="Courier New">Dlg()</font> instantiation:</span></div><div><span style="color: #366092"><br></span></div><div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;"><div><span style="font-family: Courier New;color: #366092">def test_model(qtmodeltester):</span></div></blockquote></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;"><div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;"><div><span style="font-family: Courier New;color: #366092">qtmodeltester.check(CategoryTreeModel())</span></div></blockquote></div></blockquote><div><span style="font-size: 12pt;font-family: Candara"><span style="color: #366092"><br></span></span></div><div><span style="font-size: 12pt;font-family: Candara"><span style="color: #366092"><b></b>which works (that is, the model passes the test). This also works:</span></span></div><div><span style="font-size: 12pt;font-family: Candara"><span style="color: #366092"><br></span></span></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;"><div><div><span style="font-family: Courier New;color: #366092">def test_model(qtmodeltester):</span></div></div></blockquote><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;"><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;"><div><div><span style="font-family: Courier New;color: #366092">app = QtWidgets.QApplication(sys.argv)</span></div></div></blockquote></blockquote><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;"><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;"><div><div><span style="font-family: Courier New;color: #366092">dlg = Dlg()</span></div></div></blockquote></blockquote><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;"><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;"><div><div><span style="font-family: Courier New;color: #366092">qtmodeltester.check(dlg.model)</span></div></div></blockquote></blockquote><div><div style="font-family: Candara;font-size: 12pt"><span style="color: #366092"><br></span></div><div style="font-family: Candara;font-size: 12pt"><span style="color: #366092">That is, it does not crash, and the model passes the test in this case also.</span></div><div style="font-family: Candara;font-size: 12pt"><span style="color: #366092"><br></span></div><div style="font-family: Candara;font-size: 12pt"><b><span style="color: #366092">[2]</span></b></div><span style="color: #366092">So, there doesn't seem to be anything obvious wrong with the model, at least not as far as the <font face="Consolas">pytest-qt</font> item model tester is concerned. Which means I'm not much closer to knowing why the original code I posted crashes than I was before. :-/</span></div><div><span style="color: #366092"><br></span></div><div><b><span style="color: #366092">[3]</span></b></div><div><span style="color: #366092">Regarding passing the view to the model:</span></div><div><span style="color: #366092"><br></span></div><div><span style="color: #366092">The reason I did this is because, once an item in the tree is edited, I wanted to make it the current item (lines 224-226). <font face="Courier New">setCurrentIndex()</font> is a view-level method, so I needed a reference to the view to invoke it (or thought I did). I've bumped into this several times, and always 'solved' it this way (though I never did <i>quite</i> feel like it was the right thing to do).</span></div><div><span style="color: #366092"><br></span></div><div><span style="color: #366092">What would be considered the 'right' way to handle this? Should I be connecting a signal to the <font face="Courier New">setCurrentIndex()</font> slot and emitting that?</span></div><div><span style="color: #366092"><br></span></div><div><span style="color: #366092">Thanks again!</span></div><div><span style="color: #366092"><br></span></div><div><span style="color: #366092">/John</span></div><div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;"><div></div></blockquote></div><div><div class="mb_sig"></div>
<blockquote class="history_container" type="cite" style="border-left-style: solid;border-width: 1px;margin-top: 20px;margin-left: 0px;padding-left: 10px;min-width: 500px">
<p style="margin-top: 10px;"><span style="color: #366092">On 5/4/2019 11:55:16 PM, Kyle Altendorf <sda@fstab.net> wrote:</span></p><div style="font-family:Arial,Helvetica,sans-serif"><me@the-compiler.org><span style="color: #366092">It's late so I won't promise it's testing properly... but the attached
<br>.py runs the test and passes. I'd note that you shouldn't be passing
<br>the view to the model. The intention is that the Qt defined interface
<br>is all that is needed. For example, what happens when you have two
<br>views for one model?
<br>
<br>Cheers,
<br>-kyle
</span><br></me@the-compiler.org></div></blockquote></div></div>