Results 1 to 3 of 3

Thread: QList usage in place QPtrList

  1. #1
    Join Date
    Mar 2006
    Posts
    47
    Thanks
    2
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11

    Default QList usage in place QPtrList

    Hi,
    I have to create a list of class including one structure variable and some other variables. In QT3 i am using QPtrList.
    Now I am trying to use QList but fails.

    I am using following code :
    QList<TREEITEM>list; // list contains objects of TREEITEM Class.


    TREEITEM class includes following code:

    class TREEITEM
    {

    public:
    DOSDIR MyTreeEntry; //DOSDIR is a Structure
    QString bFileName;
    QTreeWidgetItem *TreeWidgetItem;

    TREEITEM(void *MyTreeEntry1,QString bFileName1) //this is constructor
    {
    memset(this,0x00,sizeof(*this));
    DOSDIR *MyTreeEntry2=(DOSDIR*)MyTreeEntry1;
    memcpy(&MyTreeEntry,MyTreeEntry2,sizeof(DOSDIR));
    bFileName=bFileName1;
    };

    };


    Following code is used to append items in list:
    list.append(new TREEITEM((void*)(&DosDir),bFileName)); //This is showing error no matching function


    In QT3 i am using QPtrList in the same way.

    Please suggest ways how i can use QList, Please give me some code example so that i can solve my problem.


    Thanks and Regards

  2. #2
    Join Date
    Aug 2006
    Location
    Bangalore,India
    Posts
    419
    Thanks
    37
    Thanked 53 Times in 40 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: QList usage in place QPtrList

    QList<TREEITEM>list; // list contains objects of TREEITEM Class.
    Try QList<TREEITEM*>.
    (remember QList needs to be explicitly told to hold pointers unlike QPtrList)

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QList usage in place QPtrList

    Quote Originally Posted by darpan View Post
    memset(this,0x00,sizeof(*this));
    Never do that to a C++ class.

Similar Threads

  1. Accessing QList Objects
    By magikalpnoi in forum Qt Programming
    Replies: 7
    Last Post: 21st September 2006, 20:43

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.