优化TableView显示效果
This commit is contained in:
parent
e0f33eb2de
commit
dcd10a2590
|
|
@ -2,7 +2,7 @@
|
|||
level=DEBUG
|
||||
maxSize=10485760
|
||||
backups=5
|
||||
consoleOutput=true
|
||||
consoleOutput=false
|
||||
fileOutput=true
|
||||
|
||||
[Database-250303170015088]
|
||||
|
|
@ -14,3 +14,13 @@ database=postgres
|
|||
username=postgres
|
||||
password=123456
|
||||
comment=无
|
||||
|
||||
[Database-250327111518571]
|
||||
connName=MySQL
|
||||
host=127.0.0.1
|
||||
port=3306
|
||||
dbType=QMYSQL
|
||||
database=postgres
|
||||
username=postgres
|
||||
password=123456
|
||||
comment=无
|
||||
|
|
|
|||
|
|
@ -12,19 +12,25 @@ AttributeTableDelegate::~AttributeTableDelegate()
|
|||
|
||||
void AttributeTableDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const
|
||||
{
|
||||
//先执行默认绘制(包括背景、文本等基础元素)
|
||||
QStyledItemDelegate::paint(painter, option, index);
|
||||
//根据行号设置交替色
|
||||
QStyleOptionViewItem opt = option;
|
||||
initStyleOption(&opt, index);
|
||||
if ((index.row() + 1) % 2 == 0)
|
||||
{
|
||||
//opt.backgroundBrush = QBrush(QColor(243, 245, 249));
|
||||
painter->fillRect(opt.rect, QColor(240, 248, 255));
|
||||
}
|
||||
|
||||
//处理加粗字体逻辑(在基础绘制之上叠加)
|
||||
//处理加粗字体逻辑
|
||||
if(/*index.column() == 0 || */index.data(Qt::UserRole + 100).toBool())
|
||||
{
|
||||
QStyleOptionViewItem opt = option;
|
||||
initStyleOption(&opt, index);
|
||||
opt.font.setBold(true);
|
||||
//opt.palette.setColor(QPalette::Text, Qt::red);
|
||||
QStyledItemDelegate::paint(painter, opt, index);
|
||||
}
|
||||
|
||||
//先执行默认绘制(包括背景、文本等基础元素)
|
||||
QStyledItemDelegate::paint(painter, opt, index);
|
||||
|
||||
//最后绘制删除线(确保位于最顶层)
|
||||
if(m_tableView && m_tableView->model())
|
||||
{
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@ AttributeView::AttributeView(const ModelAttributeGroup& modelAttributeGroup, QWi
|
|||
, m_modelAttributeGroup(modelAttributeGroup)
|
||||
{
|
||||
m_tableView = new QTableView(this);
|
||||
// m_tableView->setAlternatingRowColors(true);
|
||||
// m_tableView->setStyleSheet("QTableView{alternate-background-color: rgb(240, 248, 255);}");
|
||||
m_tableView->verticalHeader()->setVisible(false);
|
||||
//m_tableView->horizontalHeader()->setDefaultAlignment(Qt::AlignLeft | Qt::AlignVCenter);
|
||||
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ QTabBar::tab:selected
|
|||
|
||||
QHeaderView
|
||||
{
|
||||
background-color: rgb(250, 250, 250);
|
||||
background-color: rgb(250, 250, 250);
|
||||
}
|
||||
QHeaderView::section
|
||||
{
|
||||
|
|
@ -76,15 +76,16 @@ QHeaderView::section
|
|||
|
||||
QTableView
|
||||
{
|
||||
outline:0px;
|
||||
outline:0px;
|
||||
}
|
||||
QTableView::item
|
||||
{
|
||||
border:0px;
|
||||
background-color:transparent;
|
||||
}
|
||||
QTableView::item:hover
|
||||
{
|
||||
background-color: rgb(240, 248, 255);
|
||||
background-color:transparent;
|
||||
}
|
||||
QTableView::item:selected
|
||||
{
|
||||
|
|
@ -94,7 +95,7 @@ QTableView::item:selected
|
|||
|
||||
QTreeView
|
||||
{
|
||||
outline:0px;
|
||||
outline:0px;
|
||||
}
|
||||
QTreeView::item
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue