Results 1 to 2 of 2

Thread: List implementation problem

  1. #1
    Join Date
    Oct 2009
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default List implementation problem

    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.
    Attached Images Attached Images

  2. #2
    Join Date
    Sep 2009
    Location
    Tashkent, Uzbekistan
    Posts
    107
    Thanks
    1
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: List implementation problem

    Move everything to QList before processing (
    Qt Code:
    1. QList<T> fromStdList ( const std::list<T> & list )
    To copy to clipboard, switch view to plain text mode 
    ) or reimplement QList to deal with stdlist or write your own one from scratch

Similar Threads

  1. implementation of QabstractItemModel problem
    By mikelantonio in forum Newbie
    Replies: 2
    Last Post: 7th August 2009, 16:31
  2. Problem with item selected in a list
    By 0xl33t in forum Qt Programming
    Replies: 2
    Last Post: 3rd August 2009, 17:07
  3. list view item problem..
    By addu in forum Qt Programming
    Replies: 5
    Last Post: 29th May 2009, 11:26
  4. Replies: 16
    Last Post: 7th March 2006, 15:57
  5. Problem using QValueList
    By yellowmat in forum Newbie
    Replies: 2
    Last Post: 7th February 2006, 20:01

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.