Hi all,
If I try to add no square shaped QIcon object to QTreeWidgetItem it doesn't displayed on item. Who is know the workaround for this. Please help me.
Thanks in advance,
--davit
Hi all,
If I try to add no square shaped QIcon object to QTreeWidgetItem it doesn't displayed on item. Who is know the workaround for this. Please help me.
Thanks in advance,
--davit
The shape doesn't matter. Can we see your code?
I confirm, I just tried to display a 64x20 icon in my treewidget...and it doesn't appear!
It works in Qt Designer though..
My guess is that probably you provided a relative path to the image which is incorrect runtime and the pixmap can't be created. Could you please show us the code?
Well, in my application, I use a resource file.
You can find in it (amongst others), a squared PNG image (64x64), that I always use as an icon for my tree items.
I simply resized it to 64x20 with mogrify, recompiled, and then...no more icons...
I checked the tracker, and I didn't find something relevant...
Perhaps the saved file cannot be interpreted by Qt. ( not standard PNG ).
I'm just saying...
I thought of that first, but since it's correctly displayed in QtDesigner, I think that's some damn good PNG![]()
Really annoying if it's a bug...there may be an easy workaround by making square pixmaps with transparent zones.
Could you just please show some code? It's not a bug, I assure you. I have used non-rectangular icons (define "non-rectangular" anyway... every image is rectangular) just fine many times.
Hi wysota,
The code is simple. I have implemented my own tree_widget_item class which is inherited from QTreeWidgetItem. The constructor is following:
p is correct pixmap, because if I use it for giving icon to comboBox it displays correctly.Qt Code:
{ }To copy to clipboard, switch view to plain text mode
Note: I didn't said that icon has no rectangular shape, I said that icon has no square shape.
By saying icon in this case I mean QPixmap object, from which I'm trying to create QIcon.
For rectangular Icons it works unstable (in some cases it displays, in other ones not).
Thanks,
--davit
Could you provide a little more code? Something that compiles, maybe? If you're able to reproduce the problem on a small example, it could help to solve the issue.
This seems to work fine for me (with a non-square pixmap).
Qt Code:
#include <QApplication> #include <QTreeWidget> #include <QTreeWidgetItem> #include <QtDebug> int main(int argc, char **argv){ QTreeWidget wgt; wgt.setColumnCount(1); qDebug() << px.size(); wgt.show(); return app.exec(); }To copy to clipboard, switch view to plain text mode
Last edited by wysota; 16th April 2007 at 17:04.
Hi wysota.
Your code doesn't work for attached .xpm file (icons doesn't displayed on treeWidget items).
Note: I'm using Qt4.2.2 on RHEL3.0.
Thanks,
--davit
Last edited by davit; 18th April 2007 at 11:33.
Sorry I can't attach my file. So I'll copy the content to here.
Qt Code:
/* XPM */ static char *dummy[]={ "150 1 1 1", ". c #000000", ".To copy to clipboard, switch view to plain text mode
It works just fine. It is just being scaled down so that it can fit into the item. Try a 25x10 image or change the icon size.
Thanks guys for replays.
I have found solution. It seems QTreeWidget requires to set to icon that size which has QPixmap object.
So, we need to do following:
Qt Code:
t->setIconSize(p.size());To copy to clipboard, switch view to plain text mode
Best regards,
--davit
Bookmarks