Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
QT QListViewItem with STL
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
fmalabre
Guru
Guru


Joined: 19 Jun 2002
Posts: 376
Location: Chicago

PostPosted: Tue Aug 13, 2002 4:53 pm    Post subject: QT QListViewItem with STL Reply with quote

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
View user's profile Send private message
proxy
Apprentice
Apprentice


Joined: 20 Apr 2002
Posts: 260
Location: Chantilly, VA

PostPosted: Tue Aug 13, 2002 6:18 pm    Post subject: Reply with quote

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
View user's profile Send private message
fmalabre
Guru
Guru


Joined: 19 Jun 2002
Posts: 376
Location: Chicago

PostPosted: Tue Aug 13, 2002 9:40 pm    Post subject: Reply with quote

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
View user's profile Send private message
proxy
Apprentice
Apprentice


Joined: 20 Apr 2002
Posts: 260
Location: Chantilly, VA

PostPosted: Tue Aug 13, 2002 9:52 pm    Post subject: Reply with quote

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
View user's profile Send private message
fmalabre
Guru
Guru


Joined: 19 Jun 2002
Posts: 376
Location: Chicago

PostPosted: Wed Aug 14, 2002 12:11 am    Post subject: Reply with quote

Ok, thanks.
Will let you know if I've got good information from there.
Back to top
View user's profile Send private message
credmp
Apprentice
Apprentice


Joined: 02 Jul 2002
Posts: 207
Location: Netherlands

PostPosted: Thu Aug 15, 2002 9:23 am    Post subject: Reply with quote

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
View user's profile Send private message
fmalabre
Guru
Guru


Joined: 19 Jun 2002
Posts: 376
Location: Chicago

PostPosted: Thu Aug 15, 2002 10:22 am    Post subject: Reply with quote

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
View user's profile Send private message
credmp
Apprentice
Apprentice


Joined: 02 Jul 2002
Posts: 207
Location: Netherlands

PostPosted: Thu Aug 15, 2002 3:38 pm    Post subject: Reply with quote

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
View user's profile Send private message
fmalabre
Guru
Guru


Joined: 19 Jun 2002
Posts: 376
Location: Chicago

PostPosted: Thu Aug 15, 2002 3:53 pm    Post subject: Reply with quote

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
View user's profile Send private message
credmp
Apprentice
Apprentice


Joined: 02 Jul 2002
Posts: 207
Location: Netherlands

PostPosted: Thu Aug 15, 2002 5:08 pm    Post subject: Reply with quote

You might want to do something like:

Code:

listview->setColumnWidthMode(0, QListView::Maximum);


And it should resize...

-- Arjen
Back to top
View user's profile Send private message
fmalabre
Guru
Guru


Joined: 19 Jun 2002
Posts: 376
Location: Chicago

PostPosted: Thu Aug 15, 2002 11:55 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum