thanks guys for the tips!

what i have learned so far:

it appears that maya itself does not keep track of the widget
hierarchy in my subclassed, qtDesigner generated UI.

David, i tried out your GetFullName wrapper. running this on my
QObject i still get:

# TypeError: in method 'MQtUtil_fullName', argument 1 of type 'QObject
const *' #

note that, <pointer = sip.unwrapinstance(QObject)>, is actually
returning a number of type long.
but, <mui.MQtUtil.fullName(pointer)>, seems to still be choking on it.
that concerns me a bit..
if the pointer is there, why cant the api use it to get me a pathname?

i wrote my own hacky "fullpathname" test function that returns the
full
pathname of a QWidget in question, and gave it the same QObject that i
give your wrapper. and it gives me what i would expect from your
wrapper..
accept your wrapper of course would show that maya understands widget
paths in my UI.. and my function is purely QT.

somthing like this:
def getFullQWidgetPathName(startQWidget):

    pathString = ''
    path = []
    p = startQWidget

    while type(p)!= NoneType:
        path.append('%s|'%p.objectName())
        p = p.parentWidget()

    path.reverse()
    pathString = pathString.join(path)
    return pathString.rstrip('|')

i can see my tool window in maya, its parented underneath the maya
main window, but maya seems to know nothing else about it.
trying to use any maya ui commands to parent or place the floatSlider
using the resulting path string from my hacky test function, produces:

# RuntimeError: floatSlider: Object ‘MayaWindow|tabChangedSignalTest|
centralwidget|tabWidget|qt_tabwidget_stackedwidget|tab_2|
gridLayoutWidget|sliderLayout’ not found. #

(and after much to-do i did make sure that is the actual widget
hierarchy in the pyQT UI. maya does not even see my tools main window
even though it is a child.. and yet it functions properly as a child.
everything in the UI works.. like using signals from a button to
create a sphere and a static-ui slider to move the sphere in x etc...)

so after all that, i sort of feel like maya really does not know
anything about the pyQT widget hierarchies, unless you use the loadUI
command or create the interface itself with maya commands.

however, i did find a way to parent and position a maya float slider
into this purely pyQT UI running in maya.
i downloaded and installed pymel 1.0.2.
included in this update are commands like toQObject(). i use
toQobject() to get the QObject of the float slider i create, then go
on using pyQT to parent and position the slider.
it works. the only problem is that maya still does not know the
floatSlider has been parented. so when you delete the main tool
window, it does not delete the folatslider. you can however delete it
explicitly with deleteUI maya command.

this situation is functional for what i want to do, if not ideal. i
can at least use maya specific widgets along side pyQT specific
widgets. which is great. but i still cant believe that maya knows
nothing about the widget hierarchy of the pyQT ui! and yet maya still
displays it and catches signals from it just fine.

will keep you updated as i learn more.
-thanks again,
Mark therrell

On Nov 10, 11:14 am, mtherrell <[email protected]> wrote:
> BTW, David thanks for the wrappers!
> i did not know how to use sip wrap and unwrap in order to send the
> pointers to and from QT
>
> guss i need to learn more about sip.
> im and old-school maya guy from way back.. and i used pyqt, after
> that, in a proprietary pipeline for a long time..
> but im very new to combining the two!
>
> cheers and thanks for the help!
> -mt
>
> On Nov 9, 3:18 pm, John Creson <[email protected]> wrote:
>
> > another bit to try.
>
> > give the layout a unique name and set parent to that unique name
>
> > or, dumpwidgets and weed through the dump...
>
> > for widge in cmds.lsUI(dumpWidgets=True):
> >     if widge.startswith('mywindow'):
> >        print widge
>
> > MQtUtil is also a great place to start digging.
>
> > On Tue, Nov 9, 2010 at 4:39 AM, David Moulder <[email protected]> 
> > wrote:
> > > I think you'll find this useful... some basic wraps of MQtUtil I did.
> > >  I originally got the idea for this from http://nathanhorne.com/?p=183
> > > It's well worth bookmarking these TD's and using Google Reader.  I'm 
> > > forever
> > > stealing and learning from these guys!
> > >http://pastebin.com/rE6uhtm4
> > > I've not tried to do what your attempting yet but I hope to when I get 5
> > > minutes at work...
> > > -Dave
>
> > > On Mon, Nov 8, 2010 at 6:45 PM, mtherrell <[email protected]> wrote:
>
> > >> thanks David.
>
> > >> in a function of my subclassed qtDesigner ui, i have access to the
> > >> QGridLayoutitself  and/ or the QTabWidget that has that grid layout
> > >> within it.
> > >> like this: self.sliderLayout ..
>
> > >> i am trying to get the maya fullname of that widget using
> > >> MQtUtil.fullName().
>
> > >> my problem is MQtUtil.fullName().. and its c++ ducumentaion vs. python
> > >> documentation.
> > >> MQtUtil.fullName() supposedly returns the fullname as an MString or
> > >> the control, given it's QObject.
>
> > >> but i do not know how to represent the QObject pointer in python. the
> > >> docs say fullName() requires a pointer to the QObject.
> > >> even after reading up on how python handles pointers.. i still cannot
> > >> get MQtUtil.fullName() to work in python..
>
> > >> any help or examples on how to represent the QObject as a pointer in
> > >> python.. ort how to translate the c++ docs into python in general
> > >> would be a great help!
>
> > >> thanks
> > >> -mt
> > >> On Nov 6, 12:48 pm, David Moulder <[email protected]> wrote:
> > >> > hmm, should be possible in 2011.
>
> > >> > As long as you know the fullName of the parent layout then can you not
> > >> > use
> > >> > the setParent() cmd and then add the floatSlider.
> > >> > Then get the float slider back as a QObject see the api MQtUtil i 
> > >> > think.
> > >> >  I
> > >> > think pymel has toQObject, not documented tho.
>
> > >> > I suppose you can then use signal as slots with that QObject.
>
> > >> > It's an interesting mix as it's all Qt but the implementation in both
> > >> > are
> > >> > different.
>
> > >> > -Dave
>
> > >> > On Sat, Nov 6, 2010 at 7:04 PM, mtherrell <[email protected]>
> > >> > wrote:
> > >> > > i should probably restate the problem and be a bit more clear..
>
> > >> > > my goal is to generate a maya float slider using the pymel
> > >> > > floatSlider() command, in a subclass of an interface created in qt
> > >> > > designer (and then pyuic4.. not using "loadUI").
> > >> > > i want to be able to treat this slider like any other QObject..
> > >> > > placing and attaching it into a QGridLayout in my QT interface, and
> > >> > > connecting its signals to
> > >> > > functions within my subclass. (whether by signals and slots or by the
> > >> > > callback functions of the floatslider() command itself..not sure)
>
> > >> > > my problem is that i do not know how to get the QObject that
> > >> > > represents the maya floatSlider so that i can do all these things to
> > >> > > it.
> > >> > > the object that is returned by pymel does not seem to allow QObject
> > >> > > functions. (not a QObject?)
>
> > >> > > am i missing something simple?
> > >> > > i am very new to qt and pymel..
> > >> > > its likely just newb-ism.
> > >> > > just needed a little help.
>
> > >> > > thanks.
>
> > >> > > On Nov 5, 5:02 pm, mtherrell <[email protected]> wrote:
> > >> > > > i am using pymel 1.0 in maya 2011.
> > >> > > > i am using QTDesigner to create my interface base class.
>
> > >> > > > unfortunately, (and surprisingly) QT does not have a float slider.
> > >> > > > so
> > >> > > > i need to make my float slider in my subclass of my qt interface
> > >> > > > using
> > >> > > > pymel. ( prefer not to make an intslider powers of ten bigger than
> > >> > > > my
> > >> > > > desired float range in order to approximate a float slider in QT.)
>
> > >> > > > (i am using pyuic4 to emit my interface as a .py then i subclass
> > >> > > > that .py)
>
> > >> > > > 1. are there any examples of creating a floatSlider using pymel, 
> > >> > > > and
> > >> > > > then laying it out in an already existing qt layout?
>
> > >> > > > 2. how do i get the QObject that results from creating a 
> > >> > > > floatSlider
> > >> > > > so that I can connect its signals using qt?
>
> > >> > > > 3. is it better to use qt signals  to connect the floatSlider to my
> > >> > > > functions or better to use the mel 'dragCommand' conventional
> > >> > > > callback
> > >> > > > system somehow?
>
> > >> > > > thanks for any help on using pymel floatSlider inside a qt layout..
>
> > >> > > > -mark therrell
>
> > >> > > --
> > >> > >http://groups.google.com/group/python_inside_maya
>
> > >> > --
> > >> > David Moulderhttp://www.google.com/profiles/squish3d
>
> > >> --
> > >>http://groups.google.com/group/python_inside_maya
>
> > > --
> > > David Moulder
> > >http://www.google.com/profiles/squish3d
>
> > > --
> > >http://groups.google.com/group/python_inside_maya
>
>

-- 
http://groups.google.com/group/python_inside_maya

Reply via email to