From 0321bad4c3e1209fb5cedc7b10be8ac85a9ac911 Mon Sep 17 00:00:00 2001 From: duanshengchao <519970194@qq.com> Date: Wed, 11 Jun 2025 14:58:00 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9tableview=E4=B8=AD=E7=9A=84it?= =?UTF-8?q?em=E9=80=89=E4=B8=AD=E6=97=B6=E9=A2=9C=E8=89=B2=E6=9C=AA?= =?UTF-8?q?=E4=BF=9D=E6=8C=81=E5=89=8D=E6=99=AF=E8=89=B2=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/attributeTableDelegate.cpp | 1 + source/attributeView.cpp | 2 +- ui/mainwindow.ui | 1 - 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/source/attributeTableDelegate.cpp b/source/attributeTableDelegate.cpp index 87baf7a..5ef1543 100644 --- a/source/attributeTableDelegate.cpp +++ b/source/attributeTableDelegate.cpp @@ -148,6 +148,7 @@ void AttributeTableDelegate::paint(QPainter* painter, const QStyleOptionViewItem { opt.font.setBold(true); opt.palette.setColor(QPalette::Text, Qt::red); + opt.palette.setColor(QPalette::HighlightedText, Qt::red); } //处理被选择时的背景色,注意:如果qss中有设置,会覆盖此处逻辑 diff --git a/source/attributeView.cpp b/source/attributeView.cpp index 20df92a..6ee0da6 100644 --- a/source/attributeView.cpp +++ b/source/attributeView.cpp @@ -17,7 +17,7 @@ AttributeView::AttributeView(const ModelAttributeGroup& modelAttributeGroup, QWi m_attributeGroup = DataSyncManager::instance().getGroup(m_modelAttributeGroup.groupID); m_tableView = new QTableView(this); - m_tableView->setStyleSheet("QTableView::item{padding-left:5px;} QTableView::item:selected{color:rgb(0,0,0); border:1px solid rgb(70,130,180);}"); + m_tableView->setStyleSheet("QTableView::item{padding-left:5px;} QTableView::item:selected{border:1px solid rgb(70,130,180);}"); m_tableView->verticalHeader()->setVisible(false); m_tableView->setTabKeyNavigation(false); //关闭tab键导航,对自定义Eidtor设置焦点时(比如lineEdit)会触发tab键,目前尚未清楚为什么 m_tableView->setEditTriggers(QAbstractItemView::DoubleClicked | QAbstractItemView::EditKeyPressed); //禁用自动触发编辑的所有方式(自定义代理中按要求实现,这里是双击和空格) diff --git a/ui/mainwindow.ui b/ui/mainwindow.ui index eb36006..6de10dd 100644 --- a/ui/mainwindow.ui +++ b/ui/mainwindow.ui @@ -212,7 +212,6 @@ QTableView::item:hover } QTableView::item:selected { - color: rgb(240, 240, 240); } QTreeView