<div dir="ltr">Hi Florian,<div><br></div><div>Thanks for the response. I tried your suggestion as below.</div><div><br></div><div><div>import os</div><div><br></div><div>from PyQt4 import QtGui, uic</div><div><br></div><div>FORM_CLASS, _ = uic.loadUiType(os.path.join(</div><div> os.path.dirname(__file__), 'DataCheckerModule_dialog_base.ui'))</div><div><br></div><div><br></div><div>class DataCheckerClassDialog(QtGui.QDialog, FORM_CLASS):</div><div> def __init__(self, parent=None):</div><div> """Constructor."""</div><div> super(DataCheckerClassDialog, self).__init__(parent)</div><div> # Set up the user interface from Designer.</div><div> # After setupUI you can access any designer object by doing</div><div> # self.<objectname>, and you can use autoconnect slots - see</div><div> # <a href="http://qt-project.org/doc/qt-4.8/designer-using-a-ui-file.html">http://qt-project.org/doc/qt-4.8/designer-using-a-ui-file.html</a></div><div> # #widgets-and-dialogs-with-auto-connect</div><div> self.setupUi(self)</div><div><br></div><div> def dynamicCheckBoxes(self):</div><div> """ Adds Checkboxes inside the listview dynamically based on the number of layers loaded in QGIS. """</div><div><br></div><div> canvas = qgis.utils.iface.mapCanvas()</div><div> allLayers = canvas.layers()</div><div> model = QStandardItemModel()</div><div> for i in allLayers:</div><div> item = QStandardItem('Item %s' % allLayers.name())</div><div> check = Qt.checked if randint(0,1) == 1 else Qt.Unchecked</div><div> item.setCheckState(check)</div><div> item.setCheckable(True)</div><div> model.appendRow(item)</div><div> return model</div><div><br></div><div> </div><div> DatacheckerlistView1.setModel(model)</div><div> DatacheckerlistView1.show()</div></div><div><br></div><div>And also in the main python file, i made an action like when this DatacheckerlistView1 is clicked, then it should call the class something named "addLayers"(in main Python file) which is the inheritance of dynamicCheckBoxes method from DataCheckerClassDialog (our base class of ui). As a result nothing happened when i clicked the list view after the layers had been added in QGIS. Am i missing anything?</div><div><br></div><div>Thanks,</div><div>M.Farook</div></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><p><span style="color:rgb(33,89,104);font-size:14pt" lang="EN-GB"></span></p><div style="font-size:12.8000001907349px"><b><font color="#000000">Regards</font>,</b></div><div style="font-size:12.8000001907349px"><font color="#0000ff"><b>Ahamed Farook M,</b></font></div><div style="font-size:12.8000001907349px"><font color="#0000ff"><b>Systems Programmer,</b></font></div><div style="font-size:12.8000001907349px"><font color="#0000ff"><b>KCube Consultancy Services Pvt Ltd,</b></font></div><div style="font-size:12.8000001907349px"><font color="#0000ff"><b>Eldams Road,</b></font></div><div style="font-size:12.8000001907349px"><font color="#0000ff"><b>Chennai - 18</b></font></div><div style="font-size:12.8000001907349px"><b><font color="#000000">Email</font><font color="#0000ff">: </font><a href="mailto:farook@kcubeconsulting.com" style="color:rgb(0,0,255)" target="_blank">farook@kcubeconsulting.com</a></b></div><div style="font-size:12.8000001907349px"><b><font color="#000000">Ph</font><font color="#0000ff">: +91-9952216024</font></b></div><p><span style="font-family:times new roman,serif"><span style="color:black;font-size:10pt"><br></span></span></p><span style="font-family:Vijaya,sans-serif"><b><span></span></b></span></div></div></div></div></div></div></div></div></div>
<br><div class="gmail_quote">On Sat, May 2, 2015 at 3:15 PM, Florian Bruhin <span dir="ltr"><<a href="mailto:me@the-compiler.org" target="_blank">me@the-compiler.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
* Ahamed Farook <<a href="mailto:farookrceg@gmail.com">farookrceg@gmail.com</a>> [2015-05-01 22:28:26 +0530]:<br>
<span class="">> def dynamicCheckBoxes(self):<br>
> """ Adds Checkboxes inside the listview dynamically based on the<br>
> number of layers loaded in QGIS. """<br>
><br>
> canvas = qgis.utils.iface.mapCanvas()<br>
> allLayers = canvas.layers()<br>
> model = QStandardItemModel()<br>
> for i in allLayers:<br>
> item = QStandardItem('Item %s' % allLayers.name())<br>
> check = Qt.checked if randint(0,1) == 1 else Qt.Unchecked<br>
> item.setCheckState(check)<br>
> item.setCheckable(True)<br>
> model.appendRow(item)<br>
<br>
</span>It seems you create a new QStandardItemModel here, but never use it -<br>
you'd probably have to do something like yourview.setModel(model)<br>
at some point.<br>
<span class="HOEnZb"><font color="#888888"><br>
Florian<br>
<br>
--<br>
<a href="http://www.the-compiler.org" target="_blank">http://www.the-compiler.org</a> | <a href="mailto:me@the-compiler.org">me@the-compiler.org</a> (Mail/XMPP)<br>
GPG: 916E B0C8 FD55 A072 | <a href="http://the-compiler.org/pubkey.asc" target="_blank">http://the-compiler.org/pubkey.asc</a><br>
I love long mails! | <a href="http://email.is-not-s.ms/" target="_blank">http://email.is-not-s.ms/</a><br>
</font></span><br>_______________________________________________<br>
PyQt mailing list <a href="mailto:PyQt@riverbankcomputing.com">PyQt@riverbankcomputing.com</a><br>
<a href="http://www.riverbankcomputing.com/mailman/listinfo/pyqt" target="_blank">http://www.riverbankcomputing.com/mailman/listinfo/pyqt</a><br></blockquote></div><br></div>