Hi, <br>I am programming for a multiple row deletion in QTableWidget. I used a sqlite database as the backend of QTableWidget. Below is my code. <br>I first find the row ID to be deleted, then delete all the IDs in the sqlite database, then update the remaining data to show in the QTableWidget. <br>

The first call of DelReocrdFunction is pretty good. I can delete several rows and show in the table. But the second call of DelReocrdFunction does not work. The database deletion code runs,<br>but does not actually the database (            cur.execute('DELETE FROM csvtable 
WHERE __ID__=?',(ID[0].strip()))). <br>Could someone tell me what's run with it? Thanks. <br><br><br>    def DelRecordFunction(self):<br>        '''delete an existing record'''<br>##        SelectedData = self.getSelectedData()<br>

<br>        selRanges=self.table.selectedRanges()<br><br>        ID2Delete=[]<br>        for i in range(len(selRanges)):<br>            <br>            selRange  = selRanges[i]#just take the first range<br>            topRow = selRange.topRow()<br>

            bottomRow = selRange.bottomRow()<br>            rightColumn = selRange.rightColumn()<br>            leftColumn = selRange.leftColumn()<br>            print i,topRow,bottomRow<br>            for row in range(topRow,bottomRow+1):<br>

                ID=str(self.table.item(row,0).text())<br>                ID2Delete.append(ID)<br>        print ID2Delete           <br><br>        cxn = sqlite3.connect(self.ProjectName+'.db')<br>        cur = cxn.cursor()        <br>

<br>        for ID in ID2Delete:<br>            cur.execute('DELETE FROM csvtable WHERE __ID__=?',(ID[0].strip()))<br>            print 'hi',ID<br>        cxn.commit()<br><br>        #update the data<br>        data=[]<br>

        cur.execute('select * from csvtable')<br>        for item in cur.fetchall():<br>            data.append(list(item))<br>        self.mydata=data<br>        <br>        cxn.close()<br>        print 'data len:',len(self.mydata)<br>

        self.table.refreshTable(self.header,self.mydata)<br>            <br>        print 'delete success'<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>