Results 1 to 2 of 2

Thread: Qt tree widget with check boxes iteration

  1. #1
    Join Date
    Oct 2010
    Posts
    10
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Qt tree widget with check boxes iteration

    Hi there,

    I just started learing Qt and I am trying to create a Tree widget which will have only one column and the items will have check boxes. So i managed to achieve that, and now begins my problem.

    What I want fist is every time i check on one tree item, I want to print the text of the item on a EditText area, and when I am unchecking it to remove it from the EditText area . So my issues are 2: I cant find a way to get the text from the tree item, and also at the signal- slots there is no choice for check box in the tree item, but just for selection double click and etc.

    Any help is really appreciated

    Thanks Nick

  2. #2
    Join Date
    Jul 2008
    Posts
    31
    Thanks
    1
    Thanked 5 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Qt tree widget with check boxes iteration

    Hi Nick,

    In setData which is where I presume you check your item, use the following to get the text:

    Qt Code:
    1. QString text = index.internalPointer()->data( index, Qt::DisplayRole ).toString();
    To copy to clipboard, switch view to plain text mode 

    Once this done you could emit a custom signal with the text of interest. Also, if you have written setData remember to
    Qt Code:
    1. emit dataChanged( index, index );
    To copy to clipboard, switch view to plain text mode 

    Caveat: I haven't tested this code but I think it should work...

Similar Threads

  1. Tree Widget
    By bismitapadhy in forum Qt Programming
    Replies: 1
    Last Post: 9th June 2009, 07:31
  2. how to create a tree with check on branch?
    By richardander in forum Qt Programming
    Replies: 3
    Last Post: 8th January 2009, 16:57
  3. Iteration problem
    By Pharell in forum General Programming
    Replies: 1
    Last Post: 1st October 2007, 10:56
  4. Check and Uncheck on a Dir Tree?
    By vishal.chauhan in forum Qt Programming
    Replies: 2
    Last Post: 3rd July 2007, 11:55
  5. List withembedded check boxes
    By bruccutler in forum Newbie
    Replies: 3
    Last Post: 7th March 2007, 18:17

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
  •  
Qt is a trademark of The Qt Company.