PyQt FindChild() question

1,024 views
Skip to first unread message

Gene Crucean

unread,
Jul 8, 2013, 6:04:58 PM7/8/13
to soft...@listproc.autodesk.com
Hey guys,

I'm kinda sorta new to PyQt and an trying to figure out why this is crashing Soft. I'm sure it's something really simple I'm doing wrong but could use a little guidance.


si = Application
log = si.LogMessage

camList = self.ui.cameraList.selectedItems() # QLineEdit
for sel in camList:
     log(sel.text()) # If all I do is log it's fine.
myCam = si.ActiveSceneRoot.FindChild(sel.text()) # Pretty sure this is the line that's crashing even though Soft is crashing before any output happens.
log("myCam: " + myCam.FullName)


Thoughts, tips, opinions?

Cheers


--

Tony Barbieri

unread,
Jul 8, 2013, 6:10:04 PM7/8/13
to soft...@listproc.autodesk.com
Try wrapping sel.text() in str first?  

myCam = si.ActiveSceneRoot.FindChild(str(sel.text())).  Might be returning unicode?

-tony
--
-tony

Gene Crucean

unread,
Jul 8, 2013, 6:15:11 PM7/8/13
to soft...@listproc.autodesk.com
Ah HA! Thanks Tony. Simple type cast.

I think I didn't catch it because of the text() method. I guess I figured it was already returning a string.

Thanks again.

Jeremie Passerin

unread,
Jul 8, 2013, 6:20:52 PM7/8/13
to softimage
Softimage doesn't seem to like it when you pass it a QString. 
I usually just do it like that : 

myCam = si.ActiveSceneRoot.FindChild( str( sel.text() ) ) 

Eric Thivierge

unread,
Jul 8, 2013, 6:22:03 PM7/8/13
to soft...@listproc.autodesk.com
Doens't Pyside already output str by default?


Eric Thivierge
===============
Character TD / RnD
Hybride Technologies


On July-08-13 6:20:52 PM, Jeremie Passerin wrote:
> Softimage doesn't seem to like it when you pass it a QString.
> I usually just do it like that :
>
> myCam = si.ActiveSceneRoot.FindChild( str( sel.text() ) )
>
>
> On 8 July 2013 15:04, Gene Crucean <emailgene...@gmail.com
> <mailto:emailgene...@gmail.com>> wrote:
>
> Hey guys,
>
> I'm kinda sorta new to PyQt and an trying to figure out why this
> is crashing Soft. I'm sure it's something really simple I'm doing
> wrong but could use a little guidance.
>
>
> si = Application
> log = si.LogMessage
>
> camList = self.ui.cameraList.selectedItems() *# QLineEdit*
> for sel in camList:
> log(sel.text()) *# If all I do is log it's fine.*
> myCam = si.ActiveSceneRoot.FindChild(sel.text()) *# Pretty sure
> this is the line that's crashing even though Soft is crashing
> before any output happens.*
> log("myCam: " + myCam.FullName)
>
>
> Thoughts, tips, opinions?
>
> Cheers
>
>
> --
> -Gene
> www.genecrucean.com <http://www.genecrucean.com>
>
>

Tony Barbieri

unread,
Jul 8, 2013, 6:24:51 PM7/8/13
to soft...@listproc.autodesk.com
PySide is supposed to output string and do away with all the QString stuff, but Gene is using PyQt which I believe still uses QString.


On Mon, Jul 8, 2013 at 6:22 PM, Eric Thivierge <ethiv...@hybride.com> wrote:
Doens't Pyside already output str by default?


Eric Thivierge
===============
Character TD / RnD
Hybride Technologies



On July-08-13 6:20:52 PM, Jeremie Passerin wrote:
Softimage doesn't seem to like it when you pass it a QString.
I usually just do it like that :

myCam = si.ActiveSceneRoot.FindChild( str( sel.text() ) )


On 8 July 2013 15:04, Gene Crucean <emailgene...@gmail.com
<mailto:emailgeneonthelist@gmail.com>> wrote:

    Hey guys,

    I'm kinda sorta new to PyQt and an trying to figure out why this
    is crashing Soft. I'm sure it's something really simple I'm doing
    wrong but could use a little guidance.


    si = Application
    log = si.LogMessage

    camList = self.ui.cameraList.selectedItems() *# QLineEdit*
    for sel in camList:
    log(sel.text()) *# If all I do is log it's fine.*
    myCam = si.ActiveSceneRoot.FindChild(sel.text()) *# Pretty sure

    this is the line that's crashing even though Soft is crashing
    before any output happens.*

    log("myCam: " + myCam.FullName)


    Thoughts, tips, opinions?

    Cheers


    --
    -Gene
    www.genecrucean.com <http://www.genecrucean.com>






--
-tony

Steven Caron

unread,
Jul 8, 2013, 6:29:11 PM7/8/13
to soft...@listproc.autodesk.com
i thought there was a way to configure pyqt to behave like pyside... guess not.

Eric Thivierge

unread,
Jul 8, 2013, 6:32:14 PM7/8/13
to soft...@listproc.autodesk.com
Yeah there are a few variables you need to set with SIP but it has to
happen before you init the PyQt stuff or else it will error out. So you
have to do it in the PyQtForSoftimage plugin.


Eric Thivierge
===============
Character TD / RnD
Hybride Technologies


Tim Crowson

unread,
Jul 8, 2013, 7:09:04 PM7/8/13
to soft...@listproc.autodesk.com
After you import sip, can you not use sip.setapi('QString', 2)? I seem
to recall something along those lines being possible as a way to prevent
wrapping everything in str(). Maybe I imagined it...
-Tim C.
--
Signature
Reply all
Reply to author
Forward
0 new messages