From 15e8fee2baba656a8086291fb34a4831c5260a9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20M=C3=B6ller?= Date: Fri, 16 Dec 2011 11:27:19 +0000 Subject: [PATCH] Fixed an issue where the slider size would jump around when the cubeLabel grew by a digit --- Mesh_3/demo/Mesh_3/Volume_planes_plugin.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Mesh_3/demo/Mesh_3/Volume_planes_plugin.cpp b/Mesh_3/demo/Mesh_3/Volume_planes_plugin.cpp index 1d92141adf2..362dd079de7 100644 --- a/Mesh_3/demo/Mesh_3/Volume_planes_plugin.cpp +++ b/Mesh_3/demo/Mesh_3/Volume_planes_plugin.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -257,16 +258,21 @@ public slots: QLabel* cubeLabel = new QLabel(controls); cubeLabel->setNum(static_cast(plane->getCurrentCube())); + + // Find the right width for the label to accommodate at least 9999 + QFontMetrics metric = cubeLabel->fontMetrics(); + cubeLabel->setFixedWidth(metric.width(QString("9999"))); - QSlider* slider = new Plane_slider(plane->translationVector(), id, sc, plane->manipulatedFrame(), Qt::Horizontal, controls); + QSlider* slider = new Plane_slider(plane->translationVector(), id, sc, plane->manipulatedFrame(), + Qt::Horizontal, controls); slider->setRange(0, (plane->cDim() - 1) * 100); connect(slider, SIGNAL(realChange(int)), cubeLabel, SLOT(setNum(int))); connect(plane, SIGNAL(manipulated(int)), cubeLabel, SLOT(setNum(int))); - box->addWidget(cubeLabel); box->addWidget(label); box->addWidget(slider); + box->addWidget(cubeLabel); connect(plane, SIGNAL(aboutToBeDestroyed()), controls, SLOT(deleteLater())); @@ -284,7 +290,7 @@ public slots: return; } // FIXME downcasting mode - // FIXME this will bug if two volume planes are generated simultaneously by the plug + // FIXME this will bug if two volume planes are generated simultaneously by the plugin if(Volume_plane* p = dynamic_cast< Volume_plane* >(plane)) { intersection->setX(p); } else if(Volume_plane* p = dynamic_cast< Volume_plane* >(plane)) {