22 lines
626 B
C++
22 lines
626 B
C++
|
|
//
|
||
|
|
// 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());
|
||
|
|
}
|
||
|
|
|
||
|
|
|