Qt4 QTableView-滚动时更改选择
我有一个清晰的视野。我希望在滚动时移动所选内容-以便光标始终可见 有Qt4 QTableView-滚动时更改选择,qt4,Qt4,我有一个清晰的视野。我希望在滚动时移动所选内容-以便光标始终可见 有QTableView。请选择row(rowNo),但您是否有建议将其命名为何处 理想情况下,我希望在滚动选定行时将其置于中间。可以使用method.indexAt(viewport().pos())。您可能需要稍微调整一下位置。i、 e.按页眉大小移动。当您有索引时,您可以简单地调用.row()方法您可以使用method.indexAt(viewport().pos())。您可能需要稍微调整一下位置。i、 e.按页眉大小移动。
QTableView。请选择row(rowNo)
,但您是否有建议将其命名为何处
理想情况下,我希望在滚动选定行时将其置于中间。可以使用method.indexAt(viewport().pos())。您可能需要稍微调整一下位置。i、 e.按页眉大小移动。当您有索引时,您可以简单地调用.row()方法您可以使用method.indexAt(viewport().pos())。您可能需要稍微调整一下位置。i、 e.按页眉大小移动。当您有索引时,只需调用.row()方法我就是这样做的(PyQt4): 在初始化时,我连接到滚动条事件:
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)
def onScroll(self,*args):
“确保所选行在滚动时移动-它必须始终可见。”
tableView=self.tableView
currentRow=tableView.selectionModel().currentIndex().row()
rect=tableView.viewport().rect()
topRow=tableView.indexAt(rect.topLeft()).row()
如果currentRowbottomRow:
tableView.selectRow(bottomRow)
我是这样做的(PyQt4):
在初始化时,我连接到滚动条事件:
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)
def onScroll(self,*args):
“确保所选行在滚动时移动-它必须始终可见。”
tableView=self.tableView
currentRow=tableView.selectionModel().currentIndex().row()
rect=tableView.viewport().rect()
topRow=tableView.indexAt(rect.topLeft()).row()
如果currentRowbottomRow:
tableView.selectRow(bottomRow)