baray98
6th January 2008, 03:57
I was tryin to create my widget as follows
MyWidget::MyWidget(QString description, double value,
QString unit,QWidget* parent)
:QFrame(parent)
{
//ctor
QHBoxLayout* lo = new QHBoxLayout (this);
setLayout(lo);
setContentsMargins(1,1,1,1);
QLabel* lblDescription = new QLabel (description,this);
lo->addWidget(lblDescription);
QDoubleSpinBox* sbValue = new QDoubleSpinBox(this);
sbValue->setMaximum(MaxValue);
sbValue->setValue(value);
lo->addWidget(sbValue);
QLabel* lblUnit = new QLabel (unit,this);
lo->addWidget(lblUnit);
}
I want my frame to be just enough for line edit,and two labels (since they are laid out horizontally) no more no less, This will save me some screen space. I will be re using this widget a lot in one page (widget) and they will be laid out vertically.
Now, my question is that, is there any easyway to do the tight fitting of my frame to just the three widgets?. right now there is a gap between the 2 of my MyWidget laid out Vertically.
baray98
MyWidget::MyWidget(QString description, double value,
QString unit,QWidget* parent)
:QFrame(parent)
{
//ctor
QHBoxLayout* lo = new QHBoxLayout (this);
setLayout(lo);
setContentsMargins(1,1,1,1);
QLabel* lblDescription = new QLabel (description,this);
lo->addWidget(lblDescription);
QDoubleSpinBox* sbValue = new QDoubleSpinBox(this);
sbValue->setMaximum(MaxValue);
sbValue->setValue(value);
lo->addWidget(sbValue);
QLabel* lblUnit = new QLabel (unit,this);
lo->addWidget(lblUnit);
}
I want my frame to be just enough for line edit,and two labels (since they are laid out horizontally) no more no less, This will save me some screen space. I will be re using this widget a lot in one page (widget) and they will be laid out vertically.
Now, my question is that, is there any easyway to do the tight fitting of my frame to just the three widgets?. right now there is a gap between the 2 of my MyWidget laid out Vertically.
baray98