QSettings value type=int: big positive numbers converted in negative numbers

Charles peacech at gmail.com
Tue Apr 16 14:12:52 BST 2024


I believe int is considered qint32, by specifying the type you are actually
casting your python int to 32 bit signed integer, thus the overflow.

The solution is to simply remove the type: settings.value('key')


On Tue, Apr 16, 2024 at 7:51 PM Gottfried Müller <gottfried.mueller at gmx.de>
wrote:

> Hello,
>
> reading an integer value with a huge value (for example: 2845924041) is
> converted in a negative value (-1449043255) using
>
> settings.value("bigInteger", type=int)
>
> As a workaround I read this value with type=str and convert it in the
> Python code to an integer value. Is there a way getting the right
> positive value by settings.value?
>
> Gottfried
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20240416/e6668591/attachment.htm>


More information about the PyQt mailing list