// // Created by Krad on 2021/12/8. // #include "AccountRoleComboDelegate.h" #include #include #include "db/SQLHelper.h" AccountRoleComboDelegate::AccountRoleComboDelegate(QWidget *parent):QItemDelegate(parent) { SQLHelper::QueryMap("select RoleID,RoleName from Role",map); } void AccountRoleComboDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { QString text = index.model()->data(index, Qt::DisplayRole).toString(); //绘制文本 painter->drawText(option.rect, Qt::TextWordWrap | Qt::AlignCenter , map[text].toString()); }