Vertical slider again
-
I have a slider who determine the value of "z"
i thought use a setrange for the slider (1 to 50)
Like if the vertical slider is at the bottom, the value of z will be 1
and if the slider is at the top the value of z will be 50 -
Call setRange in your MainWindow constructor.
-
Call SetRange ? i don't undertsand
-
That line:
ui->verticalSlider->setRange(1,50);
you should call it in the MainWindow constructor.And since you are using a Designer based interface you can also set the min and max values in Designer and avoid the setRange call.
-
So the z=position;
i keep it ?Sorry but even the "main constructor" it's the .cpp ? or .h ?
-
Well... Yes if you use it somewhere else.
-
Yes i use the z somewhere else
thats why i needed a range 1 - 50
-
Where exactly ? Depending on that, there's not even a need for
z
. You can get the value directly from the slider. -
It depends where i use my "z" ?
How ?
-
thank's anyway,
3 h on it, i had time to ask help
-
@Payx said in Vertical slider again:
It depends where i use my "z" ?
How ?
What do you use
z
for? Also side note, that's a horrible name for a variable locally much less one that is used at a class or global level.What @SGaist is saying is you can always get the value of the slider from the slider itself without saving it to a variable. The function
ui->verticalSlider->sliderPosition()
will always contain the same value that yourz
would.So with that in mind you can get rid of that whole overridden function and just call
sliderPosition()
when you need the value.