From 8cd5af7943e305741331af282df6e7660f2b66a7 Mon Sep 17 00:00:00 2001 From: Spiros Date: Fri, 31 May 2024 17:43:04 +0300 Subject: [PATCH] Fix header alignment --- mainwindow.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/mainwindow.cpp b/mainwindow.cpp index aaf4c72..3462507 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -285,6 +285,17 @@ void MainWindow::addSmartAttributesTable(const QJsonArray &attributes) tableWidget->setItemDelegateForColumn(0, new StatusDot(tableWidget)); tableWidget->setRowCount(attributes.size()); + for (int i = 0; i < tableWidget->columnCount(); ++i) { + QTableWidgetItem *headerItem = tableWidget->horizontalHeaderItem(i); + if (headerItem) { + if (i == 2) { + headerItem->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter); + } else if (i > 2) { + headerItem->setTextAlignment(Qt::AlignRight | Qt::AlignVCenter); + } + } + } + int row = 0; for (const QJsonValue &attr : attributes) { QJsonObject attrObj = attr.toObject();