There is an active PyQt mailing list that has lots of helpful and knowledgeable 
people on it.

https://www.riverbankcomputing.com/mailman/listinfo/pyqt

Barry


> On 25 Oct 2022, at 18:03, DFS <nos...@dfs.com> wrote:
> 
> Having problems with removeRow() on a QTableView object.
> 
> After calling removeRow(), the screen isn't updating.  It's as if the model 
> is read-only, but it's a QSqlTableModel() model, which is not read-only.
> 
> The underlying SQL is straightforward (one table) and all columns are 
> editable.
> 
> None of the editStrategies are working either.
> 
> I tried everything I can think of, including changes to the EditTriggers, but 
> no luck.  HELP!
> 
> FWIW, the same removeRow() code works fine with a QTableWidget.
> 
> -------------------------------------------------------------------
> object creation and data loading all works fine
> -------------------------------------------------------------------
> #open db connection
> qdb = QSqlDatabase.addDatabase("QSQLITE")
> qdb.setDatabaseName(dbname)
> qdb.open()
> 
> #prepare query and execute to return data
> query = QSqlQuery()
> query.prepare(cSQL)
> query.exec_()
> 
> #set model type and query
> model = QSqlTableModel()
> model.setQuery(query)
>               
> #assign model to QTableView object
> view = frm.tblPostsView
> view.setModel(model)
>               
> #get all data
> while(model.canFetchMore()): model.fetchMore()
> datarows = model.rowCount()
> 
> 
> 
> -------------------------------------------------------------------
> iterate selected rows also works fine
> SelectionMode is Extended.
> identical code works for a QTableWidget
> -------------------------------------------------------------------
> selected = tbl.selectionModel().selectedRows()
> #reverse sort the selected items to delete from bottom up
> selected = sorted(selected,reverse=True)
> for i,val in enumerate(selected):
>       tbl.model().removeRow(selected[i].row())
> 
> -- 
> https://mail.python.org/mailman/listinfo/python-list
> 

-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to