Commit 9e74f90f authored by Waqar Ahmed's avatar Waqar Ahmed Committed by Christoph Cullmann
Browse files

Fix layout for RTL

parent 361d01d5
......@@ -80,6 +80,8 @@ public:
QTextDocument doc;
const auto original =;
const auto strs =':'));
QString str =;
const QString nameColor = option.palette.color(QPalette::Link).name();
......@@ -102,10 +104,27 @@ public:
options.text = QString(); // clear old text
options.widget->style()->drawControl(QStyle::CE_ItemViewItem, &options, painter, options.widget);
// fix stuff for rtl
// QTextDocument doesn't work with RTL text out of the box so we give it a hand here by increasing
// the text width to our rect size. Icon displacement is also calculated here because 'translate()'
// later will not work.
const bool rtl = original.isRightToLeft();
if (rtl) {
auto r = options.widget->style()->subElementRect(QStyle::SE_ItemViewItemText, &options, options.widget);
auto hasIcon =<QIcon>().isNull();
if (hasIcon)
doc.setTextWidth(r.width() - 25);
// draw text
painter->translate(option.rect.x(), option.rect.y());
// leave space for icon
painter->translate(25, 0);
if (!rtl)
painter->translate(25, 0);
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment