Search code examples
pythonpyqt4qlistview

Python Qlistview output dir


i wish make little gui with pyqt4 that show the output of "dir c:\windows\" line by line I'm looking for QlistView but i don't understand how do it. Can anyone help me?


Solution

  • Try QListWidget instead of QListView. QListWidget extends QListView and adds some very helpful methods like addItems.

    I'm going to assume you know how to create the GUI part of the application using Designer.

    If you have a QListWidget object qlistwidget, the code would be:

    values = os.listdir("c:\\windows")
    
    qlist = QtCore.QStringList(map(QtCore.QString, values))
    qlistwidget.addItems(qlist)