logo
down
shadow

QTableView no selection


QTableView no selection

By : user2954959
Date : November 22 2020, 10:33 AM
To fix this issue Okay, I figured it out, and yes, if I posted the code someone would have gotten it but I'm afraid due to the size of the project, it would have probably turned just about anyone anyway. I also didn't know you could turn selecting off in the model (not the view).
code :
Qt::ItemFlags QAbstractTableModel::flags( const QModelIndex& index ) const
{
    // snip
    return Qt::NoItemFlags;
}


Share : facebook icon twitter icon
QTableView - change selection when scrolling

QTableView - change selection when scrolling


By : Tlech Celine
Date : March 29 2020, 07:55 AM
help you fix your problem I did it like this (PyQt4):
Upon init i connect to scrollbar event:
code :
    self.tableView.verticalScrollBar().valueChanged.connect(self.onScroll)
def onScroll(self, *args):
    "Ensure that selected row moves when scrolling - it must be always visible."
    tableView = self.tableView
    currentRow = tableView.selectionModel().currentIndex().row()
    rect = tableView.viewport().rect()
    topRow = tableView.indexAt(rect.topLeft()).row()
    if currentRow < topRow:
        tableView.selectRow(topRow)
    else:
        bottomRow = tableView.indexAt(rect.bottomLeft()).row()
        if currentRow > bottomRow:
            tableView.selectRow(bottomRow)
Selection with right mouse button in QTableView

Selection with right mouse button in QTableView


By : Brian Miller
Date : March 29 2020, 07:55 AM
Any of those help If you haven't already, subclass whatever built-in table view you are using (probably QTableView), and reimplement mousePressEvent(QMouseEvent* event) and mouseReleaseEvent(QMouseEvent* event) to modify the current selection.
QTableView advanced selection

QTableView advanced selection


By : vicky
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further Have you checked the signals from QItemSelectionModel, especially
How to update selection in the QTableView after drag row

How to update selection in the QTableView after drag row


By : user2608545
Date : March 29 2020, 07:55 AM
This might help you The solution is:
In function dropMimeData() need to use beginMoveRows() and andMoveRows() around place where data changed. Need to process signal QAbstractItemModel::rowsMoved of the model, where we can retrieve index of the target row.
How to inverse QTableView selection

How to inverse QTableView selection


By : Phu Le
Date : March 29 2020, 07:55 AM
Hope that helps You have to iterate to get the QModelIndex associated with each cell, and use the QItemSelection to invert the selection of each cell.
code :
def invertSelectionRemoveSelected(self):
    model = self.view.model()
    for i in range(model.rowCount()):
        for j in range(model.columnCount()):
            ix = model.index(i, j)
            self.view.selectionModel().select(ix, QItemSelectionModel.Toggle)
    # delete rows
    for ix in reversed(self.view.selectionModel().selectedRows()):
        model.removeRow(ix.row())
def invertSelectionRemoveSelected(self):
    model = self.view.model()
    rows_selected =[ix.row() for ix in self.view.selectionModel().selectedRows()]
    [model.removeRow(i) for i in reversed(range(model.rowCount())) if i not in rows_selected]
    self.view.clearSelection()
shadow
Privacy Policy - Terms - Contact Us © ourworld-yourmove.org