Results 1 to 19 of 19

Thread: Checked item in QTreeWidget?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Dec 2006
    Posts
    211
    Thanks
    27
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Question Checked item in QTreeWidget?

    Hi All,

    I am working on qt 4.2.2 on my MAC Tiger.
    I have a project in which I am change the state of a QTreeWidgetItem when an item is checked or unchecked.

    This is working fine in qt 4.2.2 but when i tried this code on qt 4.3.2 then more often the item is not get checked or unchecked when i click on the item.

    I want to ask whether it is due to Qt 4.3.2 or i have to do something different to do it.

    Thanks.

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

    Default Re: Checked item in QTreeWidget?

    Can we see the code?

  3. #3
    Join Date
    Dec 2006
    Posts
    211
    Thanks
    27
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Checked item in QTreeWidget?

    Hi,

    I m having a QTreeWidget and inserting item in the treeWidget as follows.
    Qt Code:
    1. QTreeWidgetItem *item = new QTreeWidgetItem(MyTreeWidget);
    2. item->setText(0,"My Text");
    3. item->setIcon(0,icon);
    4. item->setText(1,"--");
    5. item->setCheckState(0,Qt::Unchecked);
    To copy to clipboard, switch view to plain text mode 

    and when I click on the item in the treeWidget on Qt 4.2.2 it is checked immediately but when i am using this code in Qt 4.3.2 then the item is not checked immediately (often) and sometime it is not even checked and also giving the look of disable treeWidget.

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

    Default Re: Checked item in QTreeWidget?

    Try adding:
    Qt Code:
    1. item->setFlags(item->flags()|Qt::ItemIsUserCheckable);
    To copy to clipboard, switch view to plain text mode 

  5. #5
    Join Date
    Dec 2006
    Posts
    211
    Thanks
    27
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Checked item in QTreeWidget?

    Thanks for reply.

    but it doesnot making any difference.
    I donot know why the item is getting disable sometimes when click on item.

  6. #6
    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: Checked item in QTreeWidget?

    How do you react to check state changes? Show the slot, please.
    J-P Nurmi

  7. #7
    Join Date
    Dec 2006
    Posts
    211
    Thanks
    27
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Question Re: Checked item in QTreeWidget?

    Actually I m updating the state of the current item parent in the treeWidget and link list.

    It has 4 function which i m using and its not possible to post them.
    But I can assure that they all are running well in Qt 4.2.2 but donot know why there is a problem in the Qt 4.3.2.

    Even if I donot use them then still the item is not checked.

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

    Default Re: Checked item in QTreeWidget?

    Can you provide a minimal compilable example reproducing the problem?

  9. #9
    Join Date
    Dec 2006
    Posts
    211
    Thanks
    27
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Checked item in QTreeWidget?

    Hi,

    I m attaching a code.In it i have a treeWidget on which when i clicked sometimes item is not checked or unchecked.
    Attached Files Attached Files

  10. #10
    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: Checked item in QTreeWidget?

    Does it work properly with another style, for example with plastique?
    ./app -style plastique
    J-P Nurmi

  11. #11
    Join Date
    Dec 2006
    Posts
    211
    Thanks
    27
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Checked item in QTreeWidget?

    Yes the problem remains even after changing the Style.

  12. #12
    Join Date
    Dec 2006
    Posts
    211
    Thanks
    27
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Checked item in QTreeWidget?

    Hi,

    No Answer????.
    So Am I right it a problem of qt 4.3.2

  13. #13
    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: Checked item in QTreeWidget?

    The only problem I'm experiencing with 4.3.2 is that the area that responds to check state changes is a bit too far left. With 4.3.3 it works perfectly.
    J-P Nurmi

Similar Threads

  1. How to know wich item is clicked QTreeWidget
    By ^NyAw^ in forum Qt Programming
    Replies: 13
    Last Post: 6th November 2007, 23:47
  2. QTreeWidget select item
    By ^NyAw^ in forum Qt Programming
    Replies: 7
    Last Post: 26th October 2007, 14:26
  3. Inserting Item to a QTreeWidget from Thread?
    By vishal.chauhan in forum Qt Programming
    Replies: 3
    Last Post: 23rd June 2007, 11:23
  4. QTreeWidget item editing: want column specificity
    By McKee in forum Qt Programming
    Replies: 12
    Last Post: 10th December 2006, 22:12
  5. Removing items properly from qtreewidget item
    By Djony in forum Qt Programming
    Replies: 6
    Last Post: 21st November 2006, 12:20

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.