Results 1 to 5 of 5

Thread: How to make checked and disabled a QTreeWidgetItem

  1. #1
    Join Date
    Jan 2006
    Posts
    156
    Thanked 12 Times in 12 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default How to make checked and disabled a QTreeWidgetItem

    Hi,
    I want to set checked AND disabled an QTreeWidgetItem on QTreeWidget but :

    If I use :
    QTreeWidgetItem *item = new QTreeWidgetItem(itemParent, "myText");
    item->setCheckState(0, Qt::Checked );
    item->setFlags( Qt::ItemIsUserCheckable | Qt::ItemIsEnabled );
    Item is checked but not disabled

    and if I use :
    QTreeWidgetItem *item = new QTreeWidgetItem(itemParent, "myText");
    item->setCheckState(0, Qt::Checked );
    item->setFlags( Qt::ItemIsUserCheckable | Qt::ItemIsSelectable );
    Item is disabled but not checked

    Thanks
    Last edited by jlbrd; 4th August 2006 at 10:50.
    QDevelop, an complete Integrated Development Environment for Qt 4: http://qdevelop.org

  2. #2
    Join Date
    Mar 2006
    Posts
    48
    Thanks
    5
    Thanked 4 Times in 3 Posts

    Default Re: How to make checked and disabled a QTreeWidgetItem

    this code work
    QTreeWidgetItem *item = new QTreeWidgetItem(treeWidget, QStringList()<<"text");
    item->setFlags(Qt::ItemIsUserCheckable);
    item->setCheckState(0, Qt::Checked);

    item is disable and checked

  3. #3
    Join Date
    Jan 2006
    Posts
    156
    Thanked 12 Times in 12 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to make checked and disabled a QTreeWidgetItem

    Thanks, your code works. But I was into 4.2.0 and that does not work. A new bug certainly.
    QDevelop, an complete Integrated Development Environment for Qt 4: http://qdevelop.org

  4. The following user says thank you to jlbrd for this useful post:

    evgenM (4th August 2006)

  5. #4
    Join Date
    Mar 2006
    Posts
    48
    Thanks
    5
    Thanked 4 Times in 3 Posts

    Default Re: How to make checked and disabled a QTreeWidgetItem

    i dont think its qt4.2 bug

    your code
    item->setCheckState(0, Qt::Checked );
    item->setFlags( Qt::ItemIsUserCheckable | Qt::ItemIsSelectable );
    its wrong

    need
    item->setFlags( Qt::ItemIsUserCheckable | Qt::ItemIsSelectable );
    tem->setCheckState(0, Qt::Checked );

  6. #5
    Join Date
    Jan 2006
    Posts
    156
    Thanked 12 Times in 12 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to make checked and disabled a QTreeWidgetItem

    Yes, you have right.
    Thanks
    QDevelop, an complete Integrated Development Environment for Qt 4: http://qdevelop.org

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.