Results 1 to 5 of 5

Thread: QTreeWidget read only?

  1. #1
    Join Date
    Sep 2008
    Posts
    24
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default QTreeWidget read only?

    Hi all,

    I have a QTreeWidget in my program and am wondering of a way or making it "read only"? I can't seem to find any way of doing this. Well I did use "setDisabled(true)" which worked but then wouldn't allow the user to scroll down the widget.

    Any help would be appreciated.

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: QTreeWidget read only?

    Hi, you could use:
    Qt Code:
    1. treeWidget->editTriggers(QAbstractItemView::NoEditTriggers);
    To copy to clipboard, switch view to plain text mode 
    or set all items in it non editable.

  3. The following user says thank you to Lykurg for this useful post:

    td (15th July 2009)

  4. #3
    Join Date
    Sep 2008
    Posts
    24
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTreeWidget read only?

    Thanks. Set all the child items to disabled.

  5. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QTreeWidget read only?

    Quote Originally Posted by td View Post
    Thanks. Set all the child items to disabled.
    Earlier you said it didn't suit your needs. Anyway, see also QTreeWidgetItem::setFlags() and Qt::ItemIsEditable.
    J-P Nurmi

  6. #5
    Join Date
    Sep 2008
    Posts
    24
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTreeWidget read only?

    Quote Originally Posted by jpn View Post
    Earlier you said it didn't suit your needs.
    Doing it for the whole tree didn't (i.e. not being able to scroll down), but using it just on the child items did the trick and allowed scrolling. Thanks.

Similar Threads

  1. Filling QTreeWidget / Using QTreeView
    By stefanborries in forum Qt Programming
    Replies: 1
    Last Post: 15th April 2009, 15:25
  2. External Lib read from QBuffer on Calback problem
    By patrik08 in forum Qt Programming
    Replies: 2
    Last Post: 2nd June 2008, 19:43
  3. How to read CD with read?
    By vishal.chauhan in forum Qt Programming
    Replies: 6
    Last Post: 29th June 2007, 08:20
  4. QIODevice read()
    By ShaChris23 in forum Newbie
    Replies: 1
    Last Post: 3rd May 2007, 00:29
  5. resizing a QTreeWidget
    By drhex in forum Qt Programming
    Replies: 6
    Last Post: 27th October 2006, 22:32

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.