Fixed an issue where the slider size would jump around when the cubeLabel grew by a digit

This commit is contained in:
Philipp Möller 2011-12-16 11:27:19 +00:00
parent cbdd2fdcdb
commit 15e8fee2ba
1 changed files with 9 additions and 3 deletions

View File

@ -25,6 +25,7 @@
#include <QMessageBox>
#include <QString>
#include <QMouseEvent>
#include <QFontMetrics>
#include <cassert>
#include <iostream>
@ -258,15 +259,20 @@ public slots:
QLabel* cubeLabel = new QLabel(controls);
cubeLabel->setNum(static_cast<int>(plane->getCurrentCube()));
QSlider* slider = new Plane_slider(plane->translationVector(), id, sc, plane->manipulatedFrame(), Qt::Horizontal, controls);
// 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);
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<x_tag>* p = dynamic_cast< Volume_plane<x_tag>* >(plane)) {
intersection->setX(p);
} else if(Volume_plane<y_tag>* p = dynamic_cast< Volume_plane<y_tag>* >(plane)) {