# Overflow on widgets, better fix ?

## Recommended Posts

Posted (edited)

Hi,
I saw an overflow bug on widgets code, I noticed it on the uint32 version when slide down with mouse when it was 0, then I saw it happens also for the maximum value.
So I added a fix but I would know if you think about a better fix because I also have an int32 and double version of the widget and could be better to fix overflow here too.

const int Delta = event->globalPos().x() - m_LastPos.x();
if( ( Delta > 0 ) && ( value() < getMaximum() ) )
setValue( value() + min( Delta * singleStep(), getMaximum() - value() ) );
else if( ( Delta < 0 ) && ( value() > getMinimum() ) )
setValue( value() - min( -Delta * singleStep(), value() - getMinimum() ) );

Thanks !

Edited by Alundra

## Create an account or sign in to comment

You need to be a member in order to leave a comment

## Create an account

Sign up for a new account in our community. It's easy!

Register a new account

1. 1
2. 2
3. 3
Rutin
15
4. 4
5. 5

• 9
• 9
• 11
• 11
• 23
• ### Forum Statistics

• Total Topics
633679
• Total Posts
3013297
×