Files
GUI/src/components/AccountRoleComboDelegate.cpp

22 lines
626 B
C++
Raw Normal View History

2021-12-08 15:10:56 +08:00
//
// Created by Krad on 2021/12/8.
//
#include "AccountRoleComboDelegate.h"
#include <QComboBox>
#include <QPainter>
#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());
}