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
{
public:
Slider( Qt::Orientation orientation, QQuickItem* parent = nullptr )
Slider( Qt::Orientation orientation,
bool snap, QQuickItem* parent = nullptr )
: QskSlider( orientation, parent )
{
setBoundaries( 0, 100 );
setValue( 30 );
setStepSize( 1 );
setPageSteps( 10 );
//setSnap( true );
setSnap( snap );
if ( snap )
{
setStepSize( 5 );
setPageSteps( 4 );
}
else
{
setStepSize( 1 );
setPageSteps( 10 );
}
#if 0
connect( this, &QskSlider::valueChanged,
@ -36,10 +46,9 @@ namespace
{
public:
InputBox( QQuickItem* parent = nullptr )
: QskLinearBox( Qt::Horizontal, 3, parent )
: QskLinearBox( Qt::Horizontal, parent )
{
setSpacing( 20 );
setExtraSpacingAt( Qt::BottomEdge );
{
new QskTextInput( "Edit Me", this );
@ -59,13 +68,6 @@ namespace
input->setFixedWidth( 80 );
#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 )
: Page( Qt::Horizontal, parent )
{
auto sliderH = new Slider( Qt::Horizontal );
auto sliderV = new Slider( Qt::Vertical );
auto sliderH = new Slider( Qt::Horizontal, false );
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();
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 );
gridBox->addItem( sliderH, 0, 1, 1, -1 );
gridBox->addItem( inputBox, 1, 1, -1, -1 );
vBox->addItem( sliderH );
vBox->addItem( discreteSliderH );
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* >();
@ -101,7 +119,7 @@ void InputPage::syncValues( qreal value )
return;
blockUpdates = true;
if ( qobject_cast< const QskSlider* >( sender() ) )
{
auto spinBoxes = findChildren< QskSpinBox* >();