[PyKDE] QListBoxItem.isSelected() does not exist

Jeffrey Barish jeff_barish at earthlink.net
Wed Mar 30 22:32:20 BST 2005


Here's one that I'm pretty sure is a bug.  In the following complete
code sample, the line that is commented out tests whether the
listboxitem is selected.  However, that line produces an
AttributeError.  The line above it works correctly, but according to
the documentation selected() is obsolete.

import sys
from qt import *

class MainWindow(QMainWindow):
    def __init__(self, *args):
        QMainWindow.__init__(self, *args)

        self.lb = QListBox(self)
        self.setCentralWidget(self.lb)
        QListBoxText(self.lb, "some text")

        lbi = self.lb.firstItem()
        print "lbi.selected() = ", lbi.selected()
##        print "lbi.isSelected() = ", lbi.isSelected() # AttributeError

        print QListBoxText.__bases__[0].__dict__.get('isSelected') # the
base
        # is QListBoxItem, and 'isSelected' does not appear in its
__dict__
        # even though documentation indicates that it is a public
member.

def main(args):
    app = QApplication(args)
    win = MainWindow()
    app.setMainWidget(win)
    win.show()
    app.connect(app, SIGNAL("lastWindowClosed()"), app, SLOT("quit()"))
    app.exec_loop()

if __name__ == "__main__":
    main(sys.argv)

-- 
Jeffrey Barish




More information about the PyQt mailing list