windows - Python Qt Designer Button that creates subsequent text entries -
i'm trying make gui in qt designer has 1 text entry box , button off side inserts text entry box below first. potentially need dozen times or more.
this example code qt designer:
from pyside import qtcore, qtgui class ui_dialog(object): def setupui(self, dialog): dialog.setobjectname("dialog") dialog.resize(247, 300) self.pushbutton = qtgui.qpushbutton(dialog) self.pushbutton.setgeometry(qtcore.qrect(110, 10, 75, 23)) self.pushbutton.setobjectname("pushbutton") self.lineedit1 = qtgui.qlineedit(dialog) self.lineedit1.setgeometry(qtcore.qrect(20, 10, 31, 20)) self.lineedit1.setobjectname("lineedit1") self.lineedit2 = qtgui.qlineedit(dialog) self.lineedit2.setgeometry(qtcore.qrect(60, 10, 31, 20)) self.lineedit2.setobjectname("lineedit2") self.retranslateui(dialog) # qtcore.qobject.connect(self.pushbutton, qtcore.signal("clicked()"), dialog.add_wells) # qtcore.qmetaobject.connectslotsbyname(dialog) def retranslateui(self, dialog): dialog.setwindowtitle(qtgui.qapplication.translate("dialog", "dialog", none, qtgui.qapplication.unicodeutf8)) self.pushbutton.settext(qtgui.qapplication.translate("dialog", "pushbutton", none, qtgui.qapplication.unicodeutf8))
and code run gui:
from pyside.qtgui import * pyside.qtcore import * import sys import addentryexample class mainwindow(qdialog, addentryexample.ui_dialog): def __init__(self, parent=none): super(mainwindow, self).__init__(parent) self.setupui(self) self.connect(self.pushbutton, signal("clicked()"), self.add_entry) def add_entry(self): pass app = qapplication(sys.argv) form = mainwindow() form.show() app.exec_()
i'm struggling on how iterate each name of text box entry can pick values them later on. think placing them should require adding amount each 'setgeometry' attribute.
any appreciated!
you can use findchildren
:
lineedits = form.findchildren(qlineedit) lineedit in lineedits: print lineedit.objectname()
Comments
Post a Comment