Probably due to limited precision of float and implicit floor casting to int.
Did you ever try to compare float values ? 
Check this out:
#include <iostream>
int main(){
float n = 0.99;
while(n!=0.09){
std::cout << n << std::endl;
n-=0.01;
}
return 0;
}
#include <iostream>
int main(){
float n = 0.99;
while(n!=0.09){
std::cout << n << std::endl;
n-=0.01;
}
return 0;
}
To copy to clipboard, switch view to plain text mode
Try this to make your app work:
float f = Density*100;
slider1->setValue((int)(0.5+f));
float f = Density*100;
slider1->setValue((int)(0.5+f));
To copy to clipboard, switch view to plain text mode
The second line is equivalent to
slider1->setValue(round(f));
slider1->setValue(round(f));
To copy to clipboard, switch view to plain text mode
but Windows doesn't know how to round(), so a hack like (int)(0.5+f) is needed.
Bookmarks