<div><b>well, I found my self another way, similar but shorter.</b></div><div><b>only the printItem() function have been changed from the previous code.</b></div><div><b><br></b></div><blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<font color="#009900"><span class="Apple-tab-span" style="white-space:pre">   </span>def printItemText(self):<br><span class="Apple-tab-span" style="white-space:pre">          </span>items = self.listWidget.selectedItems()<br><span class="Apple-tab-span" style="white-space:pre">           </span>x=[]<br>
<span class="Apple-tab-span" style="white-space:pre">         </span>for i in list(items):<br><span class="Apple-tab-span" style="white-space:pre">                     </span>x.append(str(i.text()))<br><span class="Apple-tab-span" style="white-space:pre">           </span>print x<span class="Apple-tab-span" style="white-space:pre">     </span></font></blockquote>
<br><div class="gmail_quote">On Mon, Mar 26, 2012 at 9:39 PM, Christos Parliaros <span dir="ltr"><<a href="mailto:cparliaros@gmail.com">cparliaros@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><b>Is there any better, more efficient way to achieve the following:</b></div><div><br></div><blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

<font color="#009900">from PyQt4.QtCore import *<br>from PyQt4.QtGui import *<br>import ui_list<br>class Test(QDialog,ui_list.Ui_Dialog):<br><span style="white-space:pre-wrap">        </span>def __init__(self, parent=None):<br>

<span style="white-space:pre-wrap">             </span>super(Test, self).__init__(parent)<br><span style="white-space:pre-wrap">            </span>self.setupUi(self)<br><span style="white-space:pre-wrap">            </span>for i in range(10):<br>
<span style="white-space:pre-wrap">                     </span>item = QListWidgetItem("Item %i" % i)<br><span style="white-space:pre-wrap">                       </span>self.listWidget.addItem(item)<br> <span style="white-space:pre-wrap">                </span>#self.listWidget.itemClicked.connect(self.printItemText)<br>

<span style="white-space:pre-wrap">             </span>self.connect(self.listWidget, SIGNAL("itemSelectionChanged()"), self.printItemText)<br> <span style="white-space:pre-wrap">                <br></span><span style="white-space:pre-wrap">      </span>def printItemText(self):<br>

<span style="white-space:pre-wrap">             </span>items = self.listWidget.selectedItems()<br><span style="white-space:pre-wrap">               </span>x=[]<br><span style="white-space:pre-wrap">          </span>for i in range(len(items)):<br>
<span style="white-space:pre-wrap">                     </span>x.append(str(self.listWidget.selectedItems()[i].text()))<br><span style="white-space:pre-wrap">              </span>print x<span style="white-space:pre-wrap">         </span> <br>
if __name__ == "__main__":<br><span style="white-space:pre-wrap">       </span>import sys<br><span style="white-space:pre-wrap">    </span>app = QApplication(sys.argv)<br><span style="white-space:pre-wrap">  </span>form = Test()<br>

<span style="white-space:pre-wrap">     </span>form.show()<br><span style="white-space:pre-wrap">   </span>app.exec_()</font></blockquote><div><br></div><div><b>I couldnt find any way to get a list with all the selected items as text, so I had to create this loop.</b></div>

<div><b><br></b></div><div><b>Here is the code from the ui_list.py from qtdesigner:</b></div><div><br></div><div><blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

<font color="#009900">from PyQt4 import QtCore, QtGui<br>try:<br>    _fromUtf8 = QtCore.QString.fromUtf8<br>except AttributeError:<br>    _fromUtf8 = lambda s: s<br>class Ui_Dialog(object):<br>    def setupUi(self, Dialog):<br>

        Dialog.setObjectName(_fromUtf8("Dialog"))<br>        Dialog.resize(231, 315)<br>        Dialog.setWindowTitle(QtGui.QApplication.translate("Dialog", "Dialog", None, QtGui.QApplication.UnicodeUTF8))<br>

        self.listWidget = QtGui.QListWidget(Dialog)<br>        self.listWidget.setGeometry(QtCore.QRect(10, 10, 211, 291))<br>        self.listWidget.setSelectionMode(QtGui.QAbstractItemView.MultiSelection)<br>        self.listWidget.setObjectName(_fromUtf8("listWidget"))<br>

        self.retranslateUi(Dialog)<br>        QtCore.QMetaObject.connectSlotsByName(Dialog)<br>    def retranslateUi(self, Dialog):<br>        pass</font></blockquote></div><div><br></div><div><b>thanks in advance</b></div>
<span class="HOEnZb"><font color="#888888">
-- <br>Christos Parliaros<br>VFX Technical Director and Artist<br><a href="http://www.cparliaros.com" target="_blank">www.cparliaros.com</a><br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br>Christos Parliaros<br>VFX Technical Director and Artist<br><a href="http://www.cparliaros.com" target="_blank">www.cparliaros.com</a><br>