From 9ab11786b201a28e4fe82516faab00e0bd9e3f20 Mon Sep 17 00:00:00 2001 From: baldurk Date: Thu, 24 Nov 2016 17:28:42 +0100 Subject: [PATCH] Add a utility to style a QGridLayout with actual lines between elements --- qrenderdoc/Code/QRDUtils.cpp | 35 +++++++++++++++++++++++++++++++++++ qrenderdoc/Code/QRDUtils.h | 4 ++++ 2 files changed, 39 insertions(+) diff --git a/qrenderdoc/Code/QRDUtils.cpp b/qrenderdoc/Code/QRDUtils.cpp index 4617cb1ce..3744170b7 100644 --- a/qrenderdoc/Code/QRDUtils.cpp +++ b/qrenderdoc/Code/QRDUtils.cpp @@ -24,6 +24,7 @@ #include "QRDUtils.h" #include +#include #include #include #include @@ -443,3 +444,37 @@ bool QFileFilterModel::filterAcceptsRow(int source_row, const QModelIndex &sourc return true; } + +void addGridLines(QGridLayout *grid) +{ + for(int y = 0; y < grid->rowCount(); y++) + { + for(int x = 0; x < grid->columnCount(); x++) + { + QLayoutItem *item = grid->itemAtPosition(y, x); + QLayoutItem *east = grid->itemAtPosition(y, x + 1); + QLayoutItem *south = grid->itemAtPosition(y + 1, x); + + if(item == NULL) + continue; + + QWidget *w = item->widget(); + + if(w == NULL) + continue; + + QString name = w->objectName(); + + QString style; + + style += "border: solid black; border-top-width: 1px; border-left-width: 1px;"; + + if(!east || !east->widget()) + style += "border-right-width: 1px;"; + if(!south || !south->widget()) + style += "border-bottom-width: 1px;"; + + w->setStyleSheet(style); + } + } +} diff --git a/qrenderdoc/Code/QRDUtils.h b/qrenderdoc/Code/QRDUtils.h index 34514d798..7fb265e73 100644 --- a/qrenderdoc/Code/QRDUtils.h +++ b/qrenderdoc/Code/QRDUtils.h @@ -502,3 +502,7 @@ public: return m_Size; } }; + +class QGridLayout; + +void addGridLines(QGridLayout *grid);