Refactored the styling of TableView header sections
Signed-off-by: Chris Galvan <chgalvan@amazon.com>
This commit is contained in:
@@ -411,18 +411,6 @@ namespace AzQtComponents
|
||||
}
|
||||
break;
|
||||
|
||||
case CE_HeaderSection:
|
||||
{
|
||||
if (qobject_cast<const QHeaderView*>(widget))
|
||||
{
|
||||
if (TableView::drawHeaderSection(this, option, painter, widget, m_data->tableViewConfig))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case CE_ComboBoxLabel:
|
||||
{
|
||||
if (qobject_cast<const QComboBox*>(widget))
|
||||
|
||||
@@ -38,7 +38,6 @@ namespace AzQtComponents
|
||||
ConfigHelpers::read<qreal>(settings, QStringLiteral("FocusBorderWidth"), config.focusBorderWidth);
|
||||
ConfigHelpers::read<QColor>(settings, QStringLiteral("FocusBorderColor"), config.focusBorderColor);
|
||||
ConfigHelpers::read<QColor>(settings, QStringLiteral("FocusFillColor"), config.focusFillColor);
|
||||
ConfigHelpers::read<QColor>(settings, QStringLiteral("HeaderFillColor"), config.headerFillColor);
|
||||
settings.endGroup();
|
||||
|
||||
return config;
|
||||
@@ -52,7 +51,6 @@ namespace AzQtComponents
|
||||
config.focusBorderWidth = 1;
|
||||
config.focusBorderColor = QStringLiteral("#94D2FF");
|
||||
config.focusFillColor = QStringLiteral("#10ffffff");
|
||||
config.headerFillColor = QStringLiteral("#2d2d2d");
|
||||
|
||||
return config;
|
||||
}
|
||||
@@ -177,22 +175,6 @@ namespace AzQtComponents
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TableView::drawHeaderSection(const Style* style, const QStyleOption* option, QPainter* painter, const QWidget* widget, const Config& config)
|
||||
{
|
||||
Q_UNUSED(widget);
|
||||
Q_UNUSED(style);
|
||||
|
||||
const auto headerViewOption = qstyleoption_cast<const QStyleOptionHeader*>(option);
|
||||
if (!headerViewOption)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
painter->fillRect(headerViewOption->rect, config.headerFillColor);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TableView::drawFrameFocusRect(const Style* style, const QStyleOption* option, QPainter* painter, const Config& config)
|
||||
{
|
||||
Q_UNUSED(style);
|
||||
|
||||
@@ -62,7 +62,6 @@ namespace AzQtComponents
|
||||
qreal focusBorderWidth;
|
||||
QColor focusBorderColor;
|
||||
QColor focusFillColor;
|
||||
QColor headerFillColor;
|
||||
};
|
||||
|
||||
/*!
|
||||
@@ -93,7 +92,6 @@ namespace AzQtComponents
|
||||
|
||||
private:
|
||||
static bool drawHeader(const Style* style, const QStyleOption* option, QPainter* painter, const QWidget* widget, const Config& config);
|
||||
static bool drawHeaderSection(const Style* style, const QStyleOption* option, QPainter* painter, const QWidget* widget, const Config& config);
|
||||
static bool drawFrameFocusRect(const Style* style, const QStyleOption* option, QPainter* painter, const Config& config);
|
||||
static QRect itemViewItemRect(const Style* style, QStyle::SubElement element, const QStyleOptionViewItem* option, const QWidget* widget, const Config& config);
|
||||
static QSize sizeFromContents(const Style* style, QStyle::ContentsType type, const QStyleOption* option, const QSize& contentsSize, const QWidget* widget, const Config& config);
|
||||
|
||||
@@ -66,7 +66,7 @@ QTreeView QHeaderView::section
|
||||
{
|
||||
height: 24px;
|
||||
|
||||
background: #444444;
|
||||
background: #2d2d2d;
|
||||
border: none;
|
||||
|
||||
font-size: 12px;
|
||||
|
||||
@@ -134,6 +134,9 @@ TableViewPage::TableViewPage(QWidget* parent)
|
||||
auto logItemDelegate = new AzToolsFramework::Logging::LogTableItemDelegate(ui->logTableView);
|
||||
ui->logTableView->setItemDelegate(logItemDelegate);
|
||||
|
||||
// Example of changing the header section background color
|
||||
ui->logTableView->setStyleSheet("QHeaderView::section { background: transparent; }");
|
||||
|
||||
ui->qTableView->setModel(logModel);
|
||||
ui->qTableView->setAlternatingRowColors(true);
|
||||
ui->qTableView->setShowGrid(false);
|
||||
|
||||
Reference in New Issue
Block a user