Hi
Is it possible to put a generic QWidget into a Column of QListViewItem?
I want a list view where each item is composed by two colimn: a string and a KLed. I have thought to use a pixmap, but if I could use KLed is better. Some Idea?
Thanks
Hi
Is it possible to put a generic QWidget into a Column of QListViewItem?
I want a list view where each item is composed by two colimn: a string and a KLed. I have thought to use a pixmap, but if I could use KLed is better. Some Idea?
Thanks
Last edited by villy; 9th August 2006 at 10:26.
I would say that it cannot be done easily. A pixmap would be the most straight forward method, also sub-classing QListViewItem is a possibility.
qlistviewitem does not support adding widgets in it. Rather you may override its paintEvent method. Within paintEvent method you could draw your own widgets. if you look into qt's source files they did similar to build a list view item with check box support. But pixmap is easier than all.
Tanks a lot!![]()
I thought that it wasn't so easy to do without pixmap...
it's not as much hard. i'll post you a progress bar within listviewitems.
you need to subclass listviewitem.
overriding of paintCell method is enough i thing.
assume that SomeListViewItem is subclass of QListViewItem
Qt Code:
int column, int w, int alignment ) { QListViewItem::paintCell( p, cg, column, w, alignment ); double wGray = (double)m_iSinyalSeviyesi * w / 100; double wWhite = (double)w - wGray; // draw for column number 3 only // let listview draw for other columns if (column == 3) { p->setBrush(gray); p->drawRect(0, 5, (int)wGray, 32); p->setBrush(white); p->drawRect(wGray, 5, (int)wWhite, 32); p->setPen(textColor); } }To copy to clipboard, switch view to plain text mode
Last edited by jacek; 9th August 2006 at 14:29. Reason: added code tags
For a pixmap all you need is QListViewItem::setPixmap().Originally Posted by hayati
thanks hayati! You've given me a very good example![]()
Now I try to do it.
Thanks a lot!
Bookmarks