• 3378阅读
  • 1回复

求助!!!tree view的 ItemIsTristate [复制链接]

上一主题 下一主题
离线hong1985
 
只看楼主 倒序阅读 楼主  发表于: 2011-06-26
简单的示例代码如下:

model的flag()里
Qt::ItemFlags PackageTreeModel::flags(const QModelIndex &index)const //almost done
{
    if (!index.isValid())
        return 0;

    if (index.column() == PACKAGE_NAME)
        return Qt::ItemIsTristate | Qt::ItemIsSelectable |Qt::ItemIsEnabled | Qt::ItemIsUserCheckable;

。。。。
------------

model的data()里:
QVariant PackageTreeModel::data(const QModelIndex &index, introle) const

    if (role == Qt::CheckStateRole)
    {
        if (col == PACKAGE_NAME)
        {return QVariant(Qt::PartiallyChecked);

。。。。。

--------
checkbox死活显示不了 Qt::PartiallyChecked 状态。我要崩溃了。网上资料实在找不到。
(但是,可以显示Qt::Checked,和Qt::Unchecked状态。)
离线oscarboycn

只看该作者 1楼 发表于: 2011-06-29
去掉Qt::ItemIsUserCheckable; 试试
http://www.21ic.com
http://bbs.eetop.cn
http://www.eetop.cn/
http://www.eet-china.com/
http://www.netyi.net/
http://www.pcbbbs.com/
http://www.pcbtech.net/
快速回复
限100 字节
 
上一个 下一个