Details
-
Bug
-
Resolution: Done
-
P2: Important
-
5.15.2, 6.0.1
-
None
-
Debian GNU/Linux unstable amd64
-
-
a7894855f2f59028bea9cd1aef07ec1e2c713c90 (qt/qtbase/dev) 952635dabe24acf3d222acad3f959c9d33b760aa (qt/qtbase/6.1) 5f298f6e8ec1b29da4978942383b2ec54b7cd879 (qt/qtbase/6.2) e8bc2067eb2bcd40cab3515b84944408e1d56ff0 (qt/tqtc-qtbase/5.15)
Description
QTextFormat::FullWidthSelection is a property that you can set on a selection to make it highlight the full width of the line.
It works fine with left-to-right languages, but does not work with right-to-left ones (like Arabic, Persian or Hebrew): only the text is highlighted, the remaining space after it is not highlighted.
Here is a test case:
#include <QtCore/QList> #include <QtGui/QTextCursor> #include <QtGui/QTextFormat> #include <QtWidgets/QApplication> #include <QtWidgets/QTextEdit> int main(int argc, char **argv) { QApplication app(argc, argv); QTextEdit edit; edit.setPlainText("فارسی\n\nEnglish\n"); QList<QTextEdit::ExtraSelection> selections; for (int i = 0; i < 2; ++i) { QTextEdit::ExtraSelection selection; selection.format.setProperty(QTextFormat::FullWidthSelection, true); selection.format.setBackground(Qt::yellow); selection.cursor = edit.textCursor(); selections.append(selection); } selections[1].cursor.movePosition(QTextCursor::NextBlock, QTextCursor::MoveAnchor, 2); edit.setExtraSelections(selections); edit.show(); return app.exec(); }
It creates two selections: first one on RTL line and second on LTR. A screenshot is attached which demonstrates that only the second selection works as expected.
When highlighting the multi-line block, all lines except the first one are highlighted in full width, but the first one is not. See the second screenshot in this comment.
Attachments
For Gerrit Dashboard: QTBUG-91125 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
359071,3 | Fix QTextFormat::FullWidthSelection for right-to-left text layouts | dev | qt/qtbase | Status: MERGED | +2 | 0 |
359100,2 | Fix QTextFormat::FullWidthSelection for right-to-left text layouts | 6.2 | qt/qtbase | Status: MERGED | +2 | 0 |
359101,2 | Fix QTextFormat::FullWidthSelection for right-to-left text layouts | 6.1 | qt/qtbase | Status: MERGED | +2 | 0 |
359102,2 | Fix QTextFormat::FullWidthSelection for right-to-left text layouts | tqtc/lts-5.15 | qt/tqtc-qtbase | Status: MERGED | +2 | 0 |