How can QTextCursor be used to select a row in a QTextTable?
Answer:
All that needs to be done to select the whole row is get the cells for the first and last column in the row, and then getting the relevant positions from those cells. With those positions you can select the text using setPosition() and keeping the anchor. An example piece of code is as follows:
QTextTable *tt = textEdit->textCursor().currentTable();
if (!tt)
return;
QTextCursor cursor = textEdit->textCursor();
QTextTableCell cell = tt->cellAt(cursor);
QTextTableCell rowStart = tt->cellAt(cell.row(), 0);
QTextTableCell rowEnd = tt->cellAt(cell.row(), tt->columns() - 1);
cursor.setPosition(rowStart.firstCursorPosition().position());
cursor.setPosition(rowEnd.lastCursorPosition().position(), QTextCursor::KeepAnchor);
textEdit->setTextCursor(cursor);

