Я работаю над приложением PySide6 с редактором форматированного текста, включающим таблицу. Я реализовал метод вставки строки над текущей позицией курсора. Однако у меня возникла проблема: метод правильно вставляет одну строку при первом вызове, но последующие вызовы вставляют несколько строк. Этот метод не вложен ни в один цикл.
def insertRowAbove(self):
"""Inserts exactly 1 row above the current cursor position in the table."""
row, column = self.getCursorPosition()
if row is not None:
table = self.cursor.currentTable()
cursor.insertRows(row, 1)
def getCursorPosition(self) -> tuple:
"""
Returns the current row and column of the cursor in the table.
"""
table = self.cursor.currentTable()
if not table:
return None, None
cursorPositon = self.cursor.position()
cell = table.cellAt(cursorPositon)
if cell.isValid():
return cell.row(), cell.column()
return None, None
Подробнее здесь: https://stackoverflow.com/questions/790 ... stead-of-o
Python: метод вставки строк в таблицу PySide6 вставляет несколько строк вместо одной ⇐ Python
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение