Código Python:
Ver original
# -*- coding: utf-8 -*- # Form implementation generated from reading ui file 'ventana.ui' # # Created: Tue Aug 17 17:17:14 2010 # by: PyQt4 UI code generator 4.7.3 # # WARNING! All changes made in this file will be lost! #from qt import * from PyQt4 import QtCore, QtGui class Ui_MainWindow(object): def setupUi(self, MainWindow): MainWindow.setObjectName("MainWindow") MainWindow.resize(800, 600) self.centralwidget = QtGui.QWidget(MainWindow) self.centralwidget.setObjectName("centralwidget") self.pushButton = QtGui.QPushButton(self.centralwidget) self.pushButton.setGeometry(QtCore.QRect(80, 50, 105, 24)) self.pushButton.setObjectName("pushButton") self.label = QtGui.QLabel(self.centralwidget) self.label.setGeometry(QtCore.QRect(350, 70, 271, 16)) self.label.setObjectName("label") self.listView = QtGui.QListView(self.centralwidget) self.listView.setGeometry(QtCore.QRect(100, 180, 256, 192)) self.listView.setObjectName("listView") MainWindow.setCentralWidget(self.centralwidget) self.menubar = QtGui.QMenuBar(MainWindow) self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 21)) self.menubar.setObjectName("menubar") MainWindow.setMenuBar(self.menubar) self.statusbar = QtGui.QStatusBar(MainWindow) self.statusbar.setObjectName("statusbar") MainWindow.setStatusBar(self.statusbar) lvi = QtGui.QListView.QListViewItem(self.listView) lvi.setText(0,"hola mundo") self.retranslateUi(MainWindow) QtCore.QObject.connect(self.pushButton, QtCore.SIGNAL("clicked()"), MainWindow.close) QtCore.QMetaObject.connectSlotsByName(MainWindow) def retranslateUi(self, MainWindow): MainWindow.setWindowTitle(QtGui.QApplication.translate("MainWindow", "MainWindow", None, QtGui.QApplication.UnicodeUTF8)) self.pushButton.setText(QtGui.QApplication.translate("MainWindow", "PushButton", None, QtGui.QApplication.UnicodeUTF8)) self.label.setText(QtGui.QApplication.translate("MainWindow", "TextLabel", None, QtGui.QApplication.UnicodeUTF8)) if __name__ == "__main__": import sys app = QtGui.QApplication(sys.argv) MainWindow = QtGui.QMainWindow() ui = Ui_MainWindow() ui.setupUi(MainWindow) MainWindow.show() sys.exit(app.exec_())
Estoy teniendo problema en esta linea:
lvi = QListViewItem(self.listView)
Vi en muchas paginas que asi cargan elementos a las listas, pero a mi no me funciona. Me dice "NameError: global name 'QListViewItem' is not defined"
Veo que no ha sido cargado ese modulo, pero como lo hago o donde lo encuentro.