• Qt::ItemFlag Qt::ItemFlags


    include <qnamespace.h>

        enum ItemFlag {
            NoItemFlags = 0,
            ItemIsSelectable = 1,
            ItemIsEditable = 2,
            ItemIsDragEnabled = 4,
            ItemIsDropEnabled = 8,
            ItemIsUserCheckable = 16,
            ItemIsEnabled = 32,
            ItemIsAutoTristate = 64,
    #if QT_DEPRECATED_SINCE(5, 6)
            ItemIsTristate = ItemIsAutoTristate,
    #endif
            ItemNeverHasChildren = 128,
            ItemIsUserTristate = 256
        };
        Q_DECLARE_FLAGS(ItemFlags, ItemFlag)
        Q_DECLARE_OPERATORS_FOR_FLAGS(ItemFlags)
    

    This enum descripbes the properties of an item

    constant Value Description
    Qt::NoItemFlags 0 It does not have any properties set.
    Qt::ItemIsSelectable 1 It can be selected.
    Qt::ItemIsEditable 2 It can be edited.
    Qt::ItemIsFragEnabled 4 It can be dragged.
    Qt::ItemIsDropEnabled 8 It can be used as a drop target.
    Qt::ItemIsUserCheckable 16 It can be checked or unchecked by the user.
    Qt::ItemIsEnabled 32 The user can interact with the item.
    Qt::ItemIsAutoTristate 64 The item's state depends on the state of its children. This enables automatic management of the state of parent items in QTreeWidget (checked if all children are checked, unchecked if all children are unchecked, or partially checked if only some children are checked).
    Qt::ItemIsTristate 64 expired, use ItemIsAutoTristate.
    Qt::ItemNeverHasChildren 128 The item never has child items. This is used for optimization purposes only.
    Qt::ItemIsUserTristate 256 The user can cycle through three separate states. This value was added in Qt 5.5.

    Note

    1. 需要为可检查项目提供一组合适的初始状态,以指示该项目是否已checked。其中模型/视图组件已经自动处理,但需要为 QListWidgetItem、QTableWidgetItem 和 QTreeWidgetItem 的实例显式设置。

    Note that checkable items need to be given both a suitable set of flags and an initial state, indicating whether the item is checked or not. This is handled automatically for model/view components, but needs to be explicitly set for instances of QListWidgetItem, QTableWidgetItem, and QTreeWidgetItem.

    1. 如果索引设置了 Qt::ItemNeverHasChildren 标志,则重新实现 QAbstractItemModel::hasChildren 以对该索引返回 true 是未定义的行为。

    Note that it is undefined behavior to reimplement QAbstractItemModel::hasChildren to return true for an index if that index has the Qt::ItemNeverHasChildren flag set.

    1. ItemFlags是QFlags的typedef, 它存储 ItemFlag 值的 OR 组合。

    The ItemFlags type is a typedef for QFlags. It stores an OR combination of ItemFlag values.

    code

    [virtual] Qt::ItemFlags QAbstractItemModel::flags(const QModelIndex &index) const
    [virtual] bool QAbstractItemModel::hasChildren(const QModelIndex &parent = QModelIndex()) const
    
  • 相关阅读:
    vscode source control provider not registered
    MAC NVM 安装
    《高效前端:Web 高效编程与优化实践》学习笔记
    回显服务端/client
    图像处理系列(1):測地线动态轮廓(geodesic active contour)
    Pro Android学习笔记(一三八):Home Screen Widgets(4):App Widget Provider
    怎样传输SE63的翻译内容
    <html>
    概率dp sgu495
    Android Afinal框架学习(一) FinalDb 数据库操作
  • 原文地址:https://www.cnblogs.com/faithlocus/p/16484451.html
Copyright © 2020-2023  润新知