Why the QTreeWidgetItem's icon is so large?
-
The two pictures are both 16x16 pixels.
I use them by the below codes:
QTreeWidget::branch:has-children:!has-siblings:closed, QTreeWidget::branch:closed:has-children:has-siblings { border-image: none; image: url(:/images/branch_close.png); } QTreeWidget::branch:open:has-children:!has-siblings, QTreeWidget::branch:open:has-children:has-siblings { border-image: none; image: url(:/images/branch_open.png); }
But as the pic shows, the icon is too large, so I add code
treeWidget->setIconSize(QSize(4, 4));
, but it doesn't work.We can take a look at the Vmware Workstation, it's icon' size is very appropriate.
Can someone give me any advice?
-
Hi,
What size are your images ?
-
@Limer
Hi
In code , you show that you use PNG files
Doc says
"If a svg is specified, the image is scaled to the size of the contents rectangle."
http://doc.qt.io/qt-5/stylesheet-reference.html
(search for image*)So are they png or svg ?
-
@mrjj Actually, i tried both of them.
png first, but find it too large, so try to use svg again.
png and svg files are all 16x16 pixels.
What you mean is I should scale the svg to smaller size (such as 4x4 pixels)?What you mean is I should scale the png to smaller size (such as 4x4 pixels)?
-
@Limer said in Why the QTreeWidgetItem's icon is so large?:
png and svg files are all 16x16 pixels.
svg is a vector format = they actually do not have a size per se (mostly a hint) and can be scaled to any size without quality loss
-
@raven-worx Yes, you are right.
-
Hi
scaling the SVG won't help as it just scales it up.I added some free space around the actual image ( the view box in inscape)
to have them be smaller even the actual image was just the same.Like
You can just use the margin setting to get this automatically.