View previous topic :: View next topic |
Author |
Message |
fmalabre Guru
Joined: 19 Jun 2002 Posts: 376 Location: Chicago
|
Posted: Tue Aug 13, 2002 4:53 pm Post subject: QT QListViewItem with STL |
|
|
Hi,
I have a library which is based on STL, using STL lists.
I would like to dump this list in a QListView.
I tried to search on the net about this, haven't found a lot.
It seems I will have to go through all my STL list and create a bunch of QListViewItem. Is that the only way to do it?
Can't I map a STL list to a QListView? (haven't found anything on the QT doc neither).
Thanks,
Fred. |
|
Back to top |
|
|
proxy Apprentice
Joined: 20 Apr 2002 Posts: 260 Location: Chantilly, VA
|
Posted: Tue Aug 13, 2002 6:18 pm Post subject: |
|
|
the QT developers try with all their might to avoid using STL in there implementation...why? because STL is not quite so "standard" as people like to think it is. QT is a cross platform util and runs often on systems with a downright broken STL.
unfortunately, most likely you will need to use iteration and insert into the QT list structure yourself
just write a routine for it (shouldnt be too big) and never look back |
|
Back to top |
|
|
fmalabre Guru
Joined: 19 Jun 2002 Posts: 376 Location: Chicago
|
Posted: Tue Aug 13, 2002 9:40 pm Post subject: |
|
|
Ok, but still with a QT list, I still have to iterate through the QT list to show it in a QListView?
Or is there a way I can attach my QT list to a QListView? I can't find anything in the doc about this... |
|
Back to top |
|
|
proxy Apprentice
Joined: 20 Apr 2002 Posts: 260 Location: Chantilly, VA
|
Posted: Tue Aug 13, 2002 9:52 pm Post subject: |
|
|
as far as i can tell, it has to be done manually (how sucky) ...try asking in:
qt-interest@trolltech.com
they are usually very helpful |
|
Back to top |
|
|
fmalabre Guru
Joined: 19 Jun 2002 Posts: 376 Location: Chicago
|
Posted: Wed Aug 14, 2002 12:11 am Post subject: |
|
|
Ok, thanks.
Will let you know if I've got good information from there. |
|
Back to top |
|
|
credmp Apprentice
Joined: 02 Jul 2002 Posts: 207 Location: Netherlands
|
Posted: Thu Aug 15, 2002 9:23 am Post subject: |
|
|
Yes... a QListView only has QListViewItems in it (or derived classes like QmHeaderItem etc). So if you want to dump a list in there either have the list be a list of QListViewItems or create them on the go.
This might suck, but think of all the added effort to be able to load any kind of list. Internally they would have to be transformed into QListViewItems anyways...
-- Arjen |
|
Back to top |
|
|
fmalabre Guru
Joined: 19 Jun 2002 Posts: 376 Location: Chicago
|
Posted: Thu Aug 15, 2002 10:22 am Post subject: |
|
|
Right, I was just looking for a method to create all my QListViewItems for me...
Well, I guess I will have to do that manually... |
|
Back to top |
|
|
credmp Apprentice
Joined: 02 Jul 2002 Posts: 207 Location: Netherlands
|
Posted: Thu Aug 15, 2002 3:38 pm Post subject: |
|
|
should only be like 3 lines of code though...
Code: |
for (use list iterator here) {
list_view.insertItem(new QListViewItem(list_view, it->textMethod());
}
|
If you need hierachy etc it becomes more, but just dumping an list to listview is that simple.
HTH
-- Arjen |
|
Back to top |
|
|
fmalabre Guru
Joined: 19 Jun 2002 Posts: 376 Location: Chicago
|
Posted: Thu Aug 15, 2002 3:53 pm Post subject: |
|
|
Don't need hierarchie, so that should be easy.
Another problem, I update the data in my QListView, but the QListView doesn't resize as I expect.
Yes I read the doc, I spent 1 hour to try to make that work, haven't found yet.
Any idea? |
|
Back to top |
|
|
credmp Apprentice
Joined: 02 Jul 2002 Posts: 207 Location: Netherlands
|
Posted: Thu Aug 15, 2002 5:08 pm Post subject: |
|
|
You might want to do something like:
Code: |
listview->setColumnWidthMode(0, QListView::Maximum);
|
And it should resize...
-- Arjen |
|
Back to top |
|
|
fmalabre Guru
Joined: 19 Jun 2002 Posts: 376 Location: Chicago
|
Posted: Thu Aug 15, 2002 11:55 pm Post subject: |
|
|
I just tried, it doesn't work.
I have 3 levels of QListViewItem in one column, and I think it is the issue. It seems it doesn't recalculate the size with the 3 level imbricated, but only with the last level... |
|
Back to top |
|
|
|