0

I am trying to select a part of a table with text that is in a QTextBrowser (QTextEdit acts the same in this matter). I've made the table using html tags and seting append();

I can select all the text with:

cursor.movePosition(QTextCursor::End, QTextCursor::MoveAnchor);
//    cursor.movePosition(QTextCursor::StartOfLine, QTextCursor::MoveAnchor);  //does not work
cursor.movePosition(QTextCursor::Start, QTextCursor::MoveAnchor);
cursor.movePosition(QTextCursor::End, QTextCursor::KeepAnchor);
cursor.select(QTextCursor::Document);

But I cannot select one cell (or even one row). I've tried QTextCursor::NextCell and QTextCursor::NextRow as there is written in the Qt reference manual.

I've managed to select the whole row with:

cursor.movePosition(QTextCursor::End);
cursor.movePosition(QTextCursor::PreviousBlock, QTextCursor::MoveAnchor);
cursor.movePosition(QTextCursor::NextBlock, QTextCursor::KeepAnchor);
cursor.select(QTextCursor::BlockUnderCursor);

I am still unable to select only one cell. I've tried moving one cell in a row and then using cursor.selectedText(); but with no succes.

Szpaqn
  • 545
  • 5
  • 17
  • I think using `QItemSelectionModel::select()` function might help. – vahancho Mar 30 '17 at 13:14
  • @vahancho Could You give me some more details on how to use QItemSelectModel on a QTextBrowser? I thought its only for the model/view framework. – Szpaqn Mar 30 '17 at 13:31
  • Ah, sorry. I misunderstood you. I thought it's about a table view, as you mentioned table and cells. – vahancho Mar 30 '17 at 13:38

0 Answers0