Results 1 to 8 of 8

Thread: Can i change QTreeWidget to a icon mode like QListWidget??

  1. #1
    Join Date
    May 2009
    Posts
    7
    Thanks
    3

    Red face Can i change QTreeWidget to a icon mode like QListWidget??

    I want to create a QTreeWidget or qlistview or qlistwidget, that can show some date as a list that have columns and can let the user clicke a button to change the style as a icon mode.
    Qt Code:
    1. listWidget->insertItem(0, new QListWidgetItem(
    2. QIcon("copy.png"), "caterpillar"));
    3. listWidget->addItem("name");
    4. listWidget->setViewMode(QListView::IconMode);
    To copy to clipboard, switch view to plain text mode 
    but listwidget i don't kwon how to add columns

    treewidget i can add columns, but i can change list mode to icon mode

    please help me! thank so much!
    Last edited by The_hero; 29th May 2009 at 14:47. Reason: missing [code] tags

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Can i change QTreeWidget to a icon mode like QListWidget??

    I'm not sure what you mean but you can control the looks of items by changing a delegate of the view.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    May 2009
    Posts
    7
    Thanks
    3

    Default Re: Can i change QTreeWidget to a icon mode like QListWidget??

    I want add a headitem like QTreeview's column in the Qlistview or Qlistwidget.
    Sorry my english is not very good
    Last edited by The_hero; 30th May 2009 at 02:09.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Can i change QTreeWidget to a icon mode like QListWidget??

    It doesn't make much sense as QListView only has a single column so you won't see much but if you want then use QAbstractScrollArea::setViewportMargins() to "push" the contents of the viewport down and then you can place a QHeaderView there. Then you'll need to reimplement resizeEvent() for the list so that you can update the geometry of the header when the width of the list changes.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. The following user says thank you to wysota for this useful post:

    The_hero (30th May 2009)

  6. #5
    Join Date
    May 2009
    Posts
    7
    Thanks
    3

    Default Re: Can i change QTreeWidget to a icon mode like QListWidget??

    how can i let the listview like this:
    ------------------------------------------------------------
    |1 |2 |3 |4 |
    ------------------------------------------------------------
    cloude english 18 male

  7. #6
    Join Date
    Jan 2008
    Location
    Poland
    Posts
    687
    Thanks
    4
    Thanked 140 Times in 132 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Can i change QTreeWidget to a icon mode like QListWidget??

    you can't because list view has a one column always. Just use QTreeView with only one level of items, so it will look like list, and you can have as many colums you want.
    I would like to be a "Guru"

    Useful hints (try them before asking):
    1. Use Qt Assistant
    2. Search the forum

    If you haven't found solution yet then create new topic with smart question.

  8. The following user says thank you to faldzip for this useful post:

    The_hero (30th May 2009)

  9. #7
    Join Date
    May 2009
    Posts
    7
    Thanks
    3

    Default Re: Can i change QTreeWidget to a icon mode like QListWidget??

    But teacher ask we write a program that the list must have columns "name,age,department",and you can add information.It also can change to icon mode ro list mode (icon mode don't have columns)

    how can i do that??

  10. #8
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Can i change QTreeWidget to a icon mode like QListWidget??

    As wysota said in #2,, delegates
    Have a look at QItemDelegateand QStyledItemDelegate

  11. The following user says thank you to aamer4yu for this useful post:

    The_hero (5th June 2009)

Similar Threads

  1. QListwidget Icon
    By jasplye in forum Qt Programming
    Replies: 3
    Last Post: 27th November 2008, 09:17
  2. Replies: 2
    Last Post: 12th October 2008, 14:42
  3. how to sync a QTreeWidget and a QListWidget?
    By zl2k in forum Qt Programming
    Replies: 2
    Last Post: 5th September 2008, 20:55
  4. QListWidget in ListMode - still has icon space
    By high_flyer in forum Newbie
    Replies: 10
    Last Post: 30th March 2007, 19:43
  5. QTreeWidget & QListWidget different selection
    By munna in forum Qt Programming
    Replies: 9
    Last Post: 21st July 2006, 06:50

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.