Hello, can someone teach me how to solve this problem?  <br>I first created a QListView with the following two lines.<br>        self.listView = QListView(self)<br>
        self.listView.setModel(model)<br>Afterwards, I hope to get the currentItem with &quot;print self.listView.currentItem().text()&quot;, but this does not work. The error says:<br>&#39;&#39;AttributError; QListView object has no attribute &#39;currentItem&#39;<br>

How could I solve this? It seems that I  could  not use any of the members of QListView. Thanks. <br>My code is below:<br><br><br># -*- coding: utf-8 -*-<br>from PyQt4.QtCore import *<br>from PyQt4.QtGui import *<br>from PyQt4 import QtCore, QtGui<br>

import sys<br>from random import randint<br><br>class View(QWidget):<br>    def __init__(self, parent=None):<br>        super(View, self).__init__(parent)<br><br><br>        model = QStandardItemModel()<br><br>        for n in range(10):                   <br>

            item = QStandardItem(&#39;Item %s&#39; % randint(1, 100))<br><br>            check = Qt.Checked if randint(0, 1) == 1 else Qt.Unchecked<br><br>            item.setCheckState(check)<br>            item.setCheckable(True)<br>

    <br>            model.appendRow(item)<br><br>        model.connect(model, SIGNAL(&quot;itemChanged(QStandardItem *)&quot;), self.itemChanged)<br>        self.listView = QListView(self)<br>        self.listView.setModel(model)<br>

<br>        self.model = model<br>        <br>        self.resize(300, 240)<br><br>        self.contextMenu = QtGui.QMenu(self)<br>        action = QtGui.QAction(&#39;Current Item&#39;, self)<br>        self.connect(action, QtCore.SIGNAL(&quot;triggered()&quot;), self.showCurrentItem)<br>

        self.contextMenu.addAction(action)<br>    <br>    def showCurrentItem(self):<br>##        print self.listView.columns()<br>        print self.listView.currentItem().text()<br>    <br>    def contextMenuEvent(self, event):<br>

        self.contextMenu.exec_(event.globalPos())<br>##        <br>        <br>    def itemChanged(self, item):<br>        for row in range(self.model.rowCount()):<br>            item = self.model.item(row, 0)<br>            if item.checkState() == Qt.Checked:<br>

                print item.text(), &#39;is selected&#39;<br>        print &#39;--------------------------------&#39;<br><br>if __name__ == &#39;__main__&#39;:<br>    app = QApplication(sys.argv)<br>    view = View()<br>    view.show()<br>

    app.exec_()<br><br><br clear="all">---------------------------<br>He Jibo<br>Department of Psychology,<br>Beckman Institute for Advanced Science and Technology<br>University of Illinois, Urbana Champaign,<br>603 East Daniel St.,<br>

Champaign, IL 61820<br>website: <a href="http://www.hejibo.info">www.hejibo.info</a><br><br>