QT6 源(125)条目角色,枚举类 ItemDataRole :模型视图架构里,item 条目里可以存储不同角色的的数据。本枚举类描述了这些角色的集合

(1)本枚举类定义于头文件 qnamespace . h

//QVariant QComboBox::itemData(int index, int role = Qt::UserRole) const;
//模型中的每个项目都有一组与之关联的数据元素,每个数据元素都有自己的角色。
//视图使用这些角色向模型指示它需要哪种类型的数据。自定义模型应返回这些类型的数据。
enum ItemDataRole {     //本枚举类用于组合框里, Item等控件里获取条目的数据
    DisplayRole = 0,
    //The key data to be rendered in the form of text. (QString)
    
    DecorationRole = 1,
    //The data to be rendered as a decoration in the form of an icon.
    //  (QColor, QIcon or QPixmap)
    
    EditRole = 2,
    //The data in a form suitable for editing in an editor. (QString)
    
    ToolTipRole = 3, //The data displayed in the item's tooltip. (QString)
    StatusTipRole = 4, //The data displayed in the status bar. (QString)
    
    WhatsThisRole = 5,
    //The data displayed for the item in "What's This?" mode. (QString)
    
    // Metadata:Roles describing appearance and meta data (with associated types):
    FontRole =  6,
    //The font used for items rendered with the default delegate. (QFont)
    
    TextAlignmentRole =  7,
    //The alignment of the text for items rendered with the default delegate.
    //  (Qt::Alignment)
    
    BackgroundRole =  8, //The background brush used for
    //  items rendered with the default delegate. (QBrush)
    
    ForegroundRole =  9, //The foreground brush (text color, typically) used for
    //  items rendered with the default delegate. (QBrush)
    
    CheckStateRole = 10, //This role is used to obtain the
    //  checked state of an item. (Qt::CheckState)
    
    // Accessibility :Accessibility roles (with associated types):
    AccessibleTextRole = 11, //The text to be used by
    //accessibility extensions and plugins, such as screen readers. (QString)
    
    AccessibleDescriptionRole = 12,
    //A description of the item for accessibility purposes. (QString)
    
    // More general purpose
    SizeHintRole = 13,
    InitialSortOrderRole = 14,
    
    // Internal UiLib roles. Start worrying when public roles go that high.
    DisplayPropertyRole = 27,
    DecorationPropertyRole = 28,
    ToolTipPropertyRole = 29,
    StatusTipPropertyRole = 30,
    WhatsThisPropertyRole = 31,
    
    // Reserved
    UserRole = 0x0100
    //The first role that can be used for application-specific purposes
    
};

(2)给个图,易于理解

在这里插入图片描述

(3)

谢谢

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

zhangzhangkeji

谢谢支持

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值