PDA

View Full Version : List implementation problem



Kanguro
22nd November 2009, 18:19
Hi.

I'm using std::list in my application, which contains some objects. Now I want to access elements of this list using QList and three buttons. Please, take a look at attached picture.

As you can see, the "Add Entry" dialog adds a new object directly to the list, so I have no problem at this point. Problems start when it comes to editing or deleting existing object, as I must do it through the QListWidget.

How can I access the objects? The object on QListWidget are represented only by their label. I could go through the list with for() loop, create label for every single object and compare it with the label of selected object on the QListWidget, but it I can't resist the feeling it's running from the problem, not solving it. How can I store pointers or references to objects on std::list in QListWidget, while object to QListWidget may only be added by a label or QListWidgetItem?

I hope you understand what I am trying to say, if something is unclear, please let me know, so I will try to write it again in more easy-to-understand way.

Tanuki-no Torigava
22nd November 2009, 18:38
Move everything to QList before processing (
QList<T> fromStdList ( const std::list<T> & list )) or reimplement QList to deal with stdlist or write your own one from scratch