Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt6 - Svg file image drawn using delegate paint method has scaling issue
Forum Updated to NodeBB v4.3 + New Features

Qt6 - Svg file image drawn using delegate paint method has scaling issue

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 178 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    BadMan2016
    wrote on last edited by
    #1

    Hello all,

    I am using Qt 6.5.1 in Windows 11.

    I see that the checkbox svg image drawn using the delegate paint method (subclassed from QStyledItemDelegate) in a QTreeView column looks different than drawn using the css file. I mean the borders drawn are thin.

    CheckBoxResolution.png

    In the attached picture, column B checkbox is drawn using the svg file declared in the css file which is as expected. Column A is drawn using the paint method and I expect it to look same as the column A.

    When the monitor display scale settings is 125%, the drawn image in column A using the the below paint code looks the same as the column B and is ok. But when the settings is 100%, the column A image looks thin and does not look same as column B which is not good.

    How do I resolve this issue ? I am not sure if I am missing anything here. Thanks in advance. Below is the snippet of my paint method implementation.

    void ModelDelegate::paint(
           QPainter* painter,
           const QStyleOptionViewItem& option,
           const QModelIndex& index) const
        {
          ....
         else if (index.column() == Model::DisabledColumn)
              {
                painter->save();
                QStyleOptionViewItem option_copy(option);
                option_copy.icon = QIcon(":/icon/checkbox_empty.svg");;
        
                QRect rect = option_copy.rect;
                rect.adjust(3, 0, 0, 0);
                option.widget->style()->drawItemPixmap(
                painter, rect, Qt::AlignLeft | Qt::AlignVCenter, icon.pixmap(16, 16));
                painter->restore();
                return;
              }
        }
    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved