Results 1 to 2 of 2

Thread: QList and QTreeWidgetItem??

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

    Default QList and QTreeWidgetItem??

    Hi,
    Previously i am working on QT3 and using QPtrList and now i am working on QT4 and trying to use QList in place of QPtrList.

    (1)
    I declared the list as:
    QList<TREEITEM*>list; /TREEITEM is a class

    I am appending items to this list as:
    treeitem=new TREEITEM((void*)MyEntry,bFileName);
    list.append(treeitem); //Item added to list


    Now i want to iterate this created list
    In QPtrlist i am using following:
    for(treeitem=list.first();treeitem;treeitem=list.n ext())

    but in QList next() is not available. Many times i have to iterate the list.

    How i can iterate the list.

    (2)
    I am inserting checkable items in QTreeWidget and also setting icon for item in first column.

    But my problem is that check box and icon have space in between how i can minimize this space. I am using following code for this:-

    GlobalTreeWidgetItem = new QTreeWidgetItem(treeWidget);

    GlobalTreeWidgetItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsUserCheckable );
    GlobalTreeWidgetItem->setText(0,(const char*)"Root");
    GlobalTreeWidgetItem->setCheckState (0, Qt::Unchecked );
    GlobalTreeWidgetItem->setIcon ( 0, Folder );


    Thanks and Regards

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QList and QTreeWidgetItem??

    There are several ways to iterate through QList.
    I usually do:
    Qt Code:
    1. QList<type>::iterator it;
    2. for(it = mylist.begin(); it!= mylist.end(); ++it)
    3. {
    4. //do something
    5. }
    To copy to clipboard, switch view to plain text mode 
    Which by the way is very STL like.
    but in QList next() is not available. Many times i have to iterate the list.
    Well, just reads the QList docs to see what IS available instead.

Similar Threads

  1. QList usage in place QPtrList
    By darpan in forum Qt Programming
    Replies: 2
    Last Post: 25th October 2006, 15:41
  2. QTreeWidgetItem swap or move up one level problem
    By patrik08 in forum Qt Programming
    Replies: 2
    Last Post: 24th September 2006, 18:34
  3. need help with my QTreeWidgetItem List
    By patcito in forum Qt Programming
    Replies: 2
    Last Post: 6th July 2006, 18:02

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.