discrete sliders added

This commit is contained in:
Uwe Rathmann 2024-10-22 13:10:38 +02:00
parent 07bae93427
commit c3b3da2ad3

View File

@ -15,15 +15,25 @@ namespace
class Slider : public QskSlider class Slider : public QskSlider
{ {
public: public:
Slider( Qt::Orientation orientation, QQuickItem* parent = nullptr ) Slider( Qt::Orientation orientation,
bool snap, QQuickItem* parent = nullptr )
: QskSlider( orientation, parent ) : QskSlider( orientation, parent )
{ {
setBoundaries( 0, 100 ); setBoundaries( 0, 100 );
setValue( 30 ); setValue( 30 );
setStepSize( 1 ); setSnap( snap );
setPageSteps( 10 );
//setSnap( true ); if ( snap )
{
setStepSize( 5 );
setPageSteps( 4 );
}
else
{
setStepSize( 1 );
setPageSteps( 10 );
}
#if 0 #if 0
connect( this, &QskSlider::valueChanged, connect( this, &QskSlider::valueChanged,
@ -36,10 +46,9 @@ namespace
{ {
public: public:
InputBox( QQuickItem* parent = nullptr ) InputBox( QQuickItem* parent = nullptr )
: QskLinearBox( Qt::Horizontal, 3, parent ) : QskLinearBox( Qt::Horizontal, parent )
{ {
setSpacing( 20 ); setSpacing( 20 );
setExtraSpacingAt( Qt::BottomEdge );
{ {
new QskTextInput( "Edit Me", this ); new QskTextInput( "Edit Me", this );
@ -59,13 +68,6 @@ namespace
input->setFixedWidth( 80 ); input->setFixedWidth( 80 );
#endif #endif
} }
{
auto spinBox = new QskSpinBox( 0.0, 100.0, 1.0, this );
spinBox->setSizePolicy( Qt::Horizontal, QskSizePolicy::Fixed );
spinBox->setPageSteps( 5 );
spinBox->setValue( 35 );
}
} }
}; };
} }
@ -73,16 +75,32 @@ namespace
InputPage::InputPage( QQuickItem* parent ) InputPage::InputPage( QQuickItem* parent )
: Page( Qt::Horizontal, parent ) : Page( Qt::Horizontal, parent )
{ {
auto sliderH = new Slider( Qt::Horizontal ); auto sliderH = new Slider( Qt::Horizontal, false );
auto sliderV = new Slider( Qt::Vertical ); auto discreteSliderH = new Slider( Qt::Horizontal, true );
auto sliderV = new Slider( Qt::Vertical, false );
auto discreteSliderV = new Slider( Qt::Vertical, true );
auto spinBox = new QskSpinBox( 0.0, 100.0, 1.0 );
spinBox->setSizePolicy( Qt::Horizontal, QskSizePolicy::Fixed );
auto inputBox = new InputBox(); auto inputBox = new InputBox();
inputBox->setSizePolicy( Qt::Vertical, QskSizePolicy::Fixed );
auto gridBox = new QskGridBox( this ); auto vBox = new QskLinearBox( Qt::Vertical );
vBox->setSpacing( 30 );
vBox->setExtraSpacingAt( Qt::RightEdge | Qt::BottomEdge );
gridBox->addItem( sliderV, 0, 0, -1, 1 ); vBox->addItem( sliderH );
gridBox->addItem( sliderH, 0, 1, 1, -1 ); vBox->addItem( discreteSliderH );
gridBox->addItem( inputBox, 1, 1, -1, -1 ); vBox->addItem( inputBox );
vBox->addItem( spinBox );
auto mainBox = new QskLinearBox( Qt::Horizontal, this );
mainBox->setSpacing( 30 );
mainBox->addItem( sliderV );
mainBox->addItem( discreteSliderV );
mainBox->addItem( vBox );
auto inputs = findChildren< QskBoundedValueInput* >(); auto inputs = findChildren< QskBoundedValueInput* >();