Commit 371e08da authored by schurade's avatar schurade
Browse files

[FIX] linedit width for sliderwithedit widget, added a stretch so controls in...

[FIX] linedit width for sliderwithedit widget, added a stretch so controls in the tab widget don't spread
parent 87dbd038
...@@ -31,8 +31,10 @@ ...@@ -31,8 +31,10 @@
WQtDSBWidget::WQtDSBWidget( std::string name, QWidget* parent ) WQtDSBWidget::WQtDSBWidget( std::string name, QWidget* parent )
: QWidget( parent ), : QWidget( parent ),
m_name( name.c_str() ), m_name( name.c_str() ),
m_layout() m_controlLayout(),
m_pageLayout()
{ {
m_pageLayout.addLayout( &m_controlLayout );
} }
...@@ -43,31 +45,31 @@ WQtDSBWidget::~WQtDSBWidget() ...@@ -43,31 +45,31 @@ WQtDSBWidget::~WQtDSBWidget()
QPushButton* WQtDSBWidget::addPushButton( QString label ) QPushButton* WQtDSBWidget::addPushButton( QString label )
{ {
int row = m_layout.rowCount(); int row = m_controlLayout.rowCount();
QPushButton* button = new QPushButton(); QPushButton* button = new QPushButton();
button->setText( label ); button->setText( label );
m_layout.addWidget( button, row, 0 ); m_controlLayout.addWidget( button, row, 0 );
setLayout( &m_layout ); setLayout( &m_pageLayout );
return button; return button;
} }
WQtCheckBox* WQtDSBWidget::addCheckBox( QString label, bool isChecked ) WQtCheckBox* WQtDSBWidget::addCheckBox( QString label, bool isChecked )
{ {
int row = m_layout.rowCount(); int row = m_controlLayout.rowCount();
QLabel* qlabel = new QLabel( label ); QLabel* qlabel = new QLabel( label );
WQtCheckBox* checkBox = new WQtCheckBox(); WQtCheckBox* checkBox = new WQtCheckBox();
checkBox->setName( label ); checkBox->setName( label );
checkBox->setChecked( isChecked ); checkBox->setChecked( isChecked );
m_layout.addWidget( qlabel, row, 0 ); m_controlLayout.addWidget( qlabel, row, 0 );
m_layout.addWidget( checkBox, row, 1 ); m_controlLayout.addWidget( checkBox, row, 1 );
setLayout( &m_layout ); setLayout( &m_pageLayout );
return checkBox; return checkBox;
} }
...@@ -75,17 +77,17 @@ WQtCheckBox* WQtDSBWidget::addCheckBox( QString label, bool isChecked ) ...@@ -75,17 +77,17 @@ WQtCheckBox* WQtDSBWidget::addCheckBox( QString label, bool isChecked )
WQtLineEdit* WQtDSBWidget::addLineEdit( QString label, QString text ) WQtLineEdit* WQtDSBWidget::addLineEdit( QString label, QString text )
{ {
int row = m_layout.rowCount(); int row = m_controlLayout.rowCount();
QLabel* qlabel = new QLabel( label ); QLabel* qlabel = new QLabel( label );
WQtLineEdit* lineEdit = new WQtLineEdit(); WQtLineEdit* lineEdit = new WQtLineEdit();
lineEdit->setName( label ); lineEdit->setName( label );
lineEdit->setText( text ); lineEdit->setText( text );
m_layout.addWidget( qlabel, row, 0 ); m_controlLayout.addWidget( qlabel, row, 0 );
m_layout.addWidget( lineEdit, row, 1 ); m_controlLayout.addWidget( lineEdit, row, 1 );
setLayout( &m_layout ); setLayout( &m_pageLayout );
return lineEdit; return lineEdit;
} }
...@@ -93,7 +95,7 @@ WQtLineEdit* WQtDSBWidget::addLineEdit( QString label, QString text ) ...@@ -93,7 +95,7 @@ WQtLineEdit* WQtDSBWidget::addLineEdit( QString label, QString text )
WQtSliderWithEdit* WQtDSBWidget::addSliderInt( QString label, int value, int min, int max ) WQtSliderWithEdit* WQtDSBWidget::addSliderInt( QString label, int value, int min, int max )
{ {
int row = m_layout.rowCount(); int row = m_controlLayout.rowCount();
QLabel* qlabel = new QLabel( label ); QLabel* qlabel = new QLabel( label );
WQtSliderWithEdit* slider = new WQtSliderWithEdit( label ); WQtSliderWithEdit* slider = new WQtSliderWithEdit( label );
...@@ -102,14 +104,20 @@ WQtSliderWithEdit* WQtDSBWidget::addSliderInt( QString label, int value, int min ...@@ -102,14 +104,20 @@ WQtSliderWithEdit* WQtDSBWidget::addSliderInt( QString label, int value, int min
slider->setMax( max ); slider->setMax( max );
slider->setValue( value ); slider->setValue( value );
m_layout.addWidget( qlabel, row, 0 ); m_controlLayout.addWidget( qlabel, row, 0 );
m_layout.addWidget( slider, row, 1 ); m_controlLayout.addWidget( slider, row, 1 );
setLayout( &m_layout ); setLayout( &m_pageLayout );
return slider; return slider;
} }
void WQtDSBWidget::addSpacer()
{
m_pageLayout.addStretch();
setLayout( &m_pageLayout );
}
QString WQtDSBWidget::getName() QString WQtDSBWidget::getName()
{ {
return m_name; return m_name;
......
...@@ -77,6 +77,13 @@ public: ...@@ -77,6 +77,13 @@ public:
*/ */
WQtSliderWithEdit* addSliderInt( QString label, int value = 0, int min = 0, int max = 100 ); WQtSliderWithEdit* addSliderInt( QString label, int value = 0, int min = 0, int max = 100 );
/**
* helper function to add a spacer at the end
*/
void addSpacer();
/** /**
* getter for m_name * getter for m_name
*/ */
...@@ -85,7 +92,8 @@ public: ...@@ -85,7 +92,8 @@ public:
protected: protected:
private: private:
QString m_name; QString m_name;
QGridLayout m_layout; QGridLayout m_controlLayout;
QVBoxLayout m_pageLayout;
}; };
#endif // WQTDSBWIDGET_H #endif // WQTDSBWIDGET_H
...@@ -184,6 +184,8 @@ void WQtDatasetBrowser::selectTreeItem() ...@@ -184,6 +184,8 @@ void WQtDatasetBrowser::selectTreeItem()
} }
} }
} }
tab1->addSpacer();
addTabWidgetContent( tab1 ); addTabWidgetContent( tab1 );
} }
......
...@@ -73,6 +73,8 @@ void WQtSliderWithEdit::setMax( int max ) ...@@ -73,6 +73,8 @@ void WQtSliderWithEdit::setMax( int max )
fmax /= 10.0; fmax /= 10.0;
} }
m_edit.setMaxLength( length ); m_edit.setMaxLength( length );
m_edit.setMaximumWidth( m_edit.minimumSizeHint().width() * length / 2 );
m_edit.resize( m_edit.minimumSizeHint().width() * length / 2, m_edit.size().height() );
} }
void WQtSliderWithEdit::setValue( int value ) void WQtSliderWithEdit::setValue( int value )
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment