BeginResetModel () and endResetModel () doesn’t work when data contained in QStringListModel changed



  • beginResetModel () and endResetModel () doesn’t work when data contained in QStringListModel changed in my code here ,anyone can explain why ?

    @
    import sys

    from PyQt4.QtGui import *
    from PyQt4.QtCore import *

    class BoxLayout(QWidget):
    def init(self, parent=None):
    QWidget.init(self, parent)

        self.view = QTableView()
        hbox = QHBoxLayout()
        hbox.addWidget(self.view)
        self.setLayout(hbox)
        self.resize(800, 600)
    
        self.lst=[]
        self.stringListModel=QStringListModel (self.lst)
        self.view.setModel(self.stringListModel)
        
        self.timer = QTimer(self);
        self.timer.timeout.connect(self.timerHit)
        self.timer.start(1000)
        
    def timerHit(self):
        self.stringListModel.beginResetModel ()
        
        self.lst.append(QTime.currentTime().toString())
        #self.stringListModel.setStringList(self.lst)
        self.stringListModel.endResetModel ()
    

    app = QApplication(sys.argv)
    qb = BoxLayout()
    qb.show()
    sys.exit(app.exec_())

    @


  • Lifetime Qt Champion

    Hi,

    Please don't post the same thread in multiple sub-forum

    "Duplicate":http://qt-project.org/forums/viewthread/34158/


  • Moderators

    Closed for duplication


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.