Inside Sabertooth
Learn how Sabertooth uses 3ds Max to create 3D interactive projects, including HBO Go’s Game of Thrones interactive experience
  • 1/3
You are here: Forum Home / Autodesk® Maya® / Python / Read QT lineEdits in Python?
  RSS 2.0 ATOM  

Read QT lineEdits in Python?
Rate this thread
 
54045
 
Permlink of this thread  
avatar
  • 3v1l
  • Posted: 06 April 2011 08:32 PM
  • Total Posts: 10
  • Joined: 23 October 2007 09:43 PM

Hi,
I have a problem reading the content of lineEdits from an UI.
I have created an UI with QTDesigner with one lineEdit named “myTextField” and one button.
I gave the button the dynamic attribute to run the doIt() function.

import pymel
# load QT user-interface and show it
dialog pm.loadUI(f='C:\\work\\vnxMaya\\src\\input.ui')
pm.showWindow(dialog)

def doIt():
    
myT myT mc.textField('myTextField'query=Truetext=True)
    print 
myT

Now sometime it works and prints the right values that are in the lineEdit-field and if I change the text in the lineEdit it will update correctly.
But most of the time it will print an empty string (’’) and even writing sth different into the lineEdit-field as default or interactive wonn’t change the output. I wrote the same code with mel and python (without pymel) and the results are the same.
Any ideas, why the myT variable doesn’t update?



Replies: 0
avatar
  • ldunham1
  • Posted: 16 September 2011 11:52 PM

just wondering, why do you declare the variable in itself twice?

myT myT mc.textField('myTextField'query=Truetext=True)


Lee Dunham | Character TD
ldunham.blogspot.com

Replies: 0
avatar

why do you have myT twice? and also, how do you declare your event linking in qt designer? personnally i prefer just defining the names in qt and have a function called _defineCallbacks() in my python code to do something like

cmds.button("myButton"edit Truecommand self.doIt)


Replies: 0