Results 1 to 4 of 4

Thread: QTreeWidget selection

  1. #1
    Join Date
    Jan 2006
    Location
    Leiden, the Netherlands
    Posts
    43
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default QTreeWidget selection

    Hello,

    I want a QTreeWidget with multiple selection (with CTRL keys as QAbstractItemView::ExtendedSelection). Multiple selecting items should turn multiple items blue. Like the pic shown in this thread:
    http://www.qtcentre.org/forum/f-qt-p...low--2662.html

    Howver, I set my tree to Selection: QAbstractItemView::ExtendedSelection, SelectionBehavior to: QAbstractItemView::SelectRows

    First: I only see a rubberband around the selected column and second I cannot multiple select rows.

    What am I doing wrong?

    Arthur
    Last edited by Arthur; 9th March 2007 at 16:11.

  2. #2
    Join Date
    Jan 2006
    Location
    Paris, France
    Posts
    227
    Thanks
    3
    Thanked 21 Times in 21 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QTreeWidget selection

    Sorry, I misread your post

    Can you post a sample of code (compilable ?)

  3. #3
    Join Date
    Jan 2006
    Location
    Leiden, the Netherlands
    Posts
    43
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTreeWidget selection

    Qt Code:
    1. ui.tree->setColumnCount(3);
    2. QStringList labels;
    3. labels << tr("Aap") << tr("Noot") << tr("Mies");
    4. ui.tree-->setHeaderLabels(labels);
    5.  
    6. for(int i = 0; i < 10; ++i)
    7. {
    8. QTreeWidgetItem * pItem = new QTreeWidgetItem(ui.tree);
    9. pItem->setText(0, "Aap");
    10. pItem->setText(1, "Noot");
    11. pItem->setText(2, "Mies");
    12. }
    To copy to clipboard, switch view to plain text mode 

    In fact, this tree works fine. I have multiple row selection and selected rows turn blue...
    however if I make items editable:

    Qt Code:
    1. pItem->setFlags(Qt::ItemIsEditable);
    To copy to clipboard, switch view to plain text mode 

    I only see a rubberband around the column I want to change and no selected row. Why?
    Also I cannot multiple select rows...
    Last edited by Arthur; 9th March 2007 at 16:16.

  4. #4
    Join Date
    May 2006
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QTreeWidget selection

    Quote Originally Posted by Arthur View Post
    Qt Code:
    1. ui.tree->setColumnCount(3);
    2. QStringList labels;
    3. labels << tr("Aap") << tr("Noot") << tr("Mies");
    4. ui.tree-->setHeaderLabels(labels);
    5.  
    6. for(int i = 0; i < 10; ++i)
    7. {
    8. QTreeWidgetItem * pItem = new QTreeWidgetItem(ui.tree);
    9. pItem->setText(0, "Aap");
    10. pItem->setText(1, "Noot");
    11. pItem->setText(2, "Mies");
    12. }
    To copy to clipboard, switch view to plain text mode 

    In fact, this tree works fine. I have multiple row selection and selected rows turn blue...
    however if I make items editable:

    Qt Code:
    1. pItem->setFlags(Qt::ItemIsEditable);
    To copy to clipboard, switch view to plain text mode 

    I only see a rubberband around the column I want to change and no selected row. Why?
    Also I cannot multiple select rows...
    Try this.

    pItem->setFlags(pItem->flags() | Qt::ItemIsEditable);

    When You write
    pItem->setFlags(Qt::ItemIsEditable); you clean all previus flags.

Similar Threads

  1. [SOLVED] QTreeView drawing selection with icons
    By Timewarp in forum Qt Programming
    Replies: 7
    Last Post: 7th February 2013, 07:52
  2. Replies: 1
    Last Post: 8th March 2007, 10:12
  3. resizing a QTreeWidget
    By drhex in forum Qt Programming
    Replies: 6
    Last Post: 27th October 2006, 22:32
  4. CheckBox and selection in QTableView
    By Mike Krus in forum Qt Programming
    Replies: 1
    Last Post: 21st September 2006, 20:31
  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.