Details
-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
5.12
-
None
Description
How to use sample code.
- press 0
- select row 1- 2, column 0 by mouse and merge the selected cells by pressing 1.
- do the same thing at all columns
- insertColumns by pressing 2
- the test application falls.
It seems that the inserted column cells are randomly.
no assertion with PySide...
from:
row span1 | row span1 | row span1 |
row span1 | row span1 | row span1 |
row span1 | row span1 | row span1 |
to:
row span1 | row span1 | row span1 |
row span2 | row span2 | row span2 |
from PySide2 import QtGui from PySide2 import QtCore from PySide2 import QtWidgets import sys, os import PySide2 #Bug If you merge cells at all columns, and insertColumns, application falls. class TextEdit(QtWidgets.QTextEdit): def __init__(self, parent=None): super(TextEdit, self).__init__(parent=None) def keyPressEvent(self, event): if event.key() == QtCore.Qt.Key_0: tc = self.textCursor() columnwidthconstraints = [QtGui.QTextLength(QtGui.QTextLength.VariableLength, 100) for i in range(3)] tableformat = QtGui.QTextTableFormat() tableformat.setColumnWidthConstraints(columnwidthconstraints) tableformat.setWidth(300) tc.insertTable(3, 3, tableformat) return if event.key() == QtCore.Qt.Key_1: tc = self.textCursor() currentTable = tc.currentTable() if currentTable is not None: currentTable.mergeCells(tc) return if event.key() == QtCore.Qt.Key_2: tc = self.textCursor() currentTable = tc.currentTable() if currentTable is not None: cell = currentTable.cellAt(tc) currentTable.insertColumns(cell.column(), 1) return return QtWidgets.QTextEdit.keyPressEvent(self, event) def main(): QtWidgets.QApplication([]) t = TextEdit() t.setGeometry(300, 300, 500, 100) t.show() sys.exit(QtWidgets.QApplication.exec_()) if __name__ == "__main__": main()
Other things:
The errors appears at different aspects but the reason is ascribed to insertColumns method.
For example,
The assignments of cells are changed and scattered.