Account Table form
This commit is contained in:
21
src/components/AccountRoleComboDelegate.cpp
Normal file
21
src/components/AccountRoleComboDelegate.cpp
Normal file
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// 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());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user