[PATCH] Horizontally align labels on info widget page.

amit.k.chaudhuri at gmail.com amit.k.chaudhuri at gmail.com
Fri May 10 15:56:04 PDT 2013


From: Amit Chaudhuri <amit.k.chaudhuri at gmail.com>

Left aligning text values looked wrong.

Use Qobject cast to filter labels from any other qobjects around and
set alignment. Doing this via Qt Designer would be tedious.

Signed-off-by: Amit Chaudhuri <amit.k.chaudhuri at gmail.com>
---
 qt-ui/maintab.cpp |    8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp
index 4e7f6b3..e1ac7c2 100644
--- a/qt-ui/maintab.cpp
+++ b/qt-ui/maintab.cpp
@@ -21,6 +21,14 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent),
 	ui->setupUi(this);
 	ui->cylinders->setModel(cylindersModel);
 	ui->weights->setModel(weightModel);
+
+	/* example of where code is more concise than Qt designer */
+	QList<QObject *> infoTabWidgets = ui->infoTab->children();
+	Q_FOREACH( QObject* obj, infoTabWidgets ){
+		QLabel* label = qobject_cast<QLabel *>(obj);
+		if (label)
+			label->setAlignment(Qt::AlignHCenter);
+	}
 }
 
 void MainTab::clearEquipment()
-- 
1.7.10.4



More information about the subsurface mailing list