[PyQt] question re Atext drag and drop in PyQt3

Hans-Peter Jansen hpj at urpla.net
Sun Apr 29 16:43:53 BST 2007


Am Freitag, 27. April 2007 23:43 schrieb Tony Willis:
> I hope that someone can help me with the following. I'm attempting
> to drag and drop some floating point numbers from one widget to
> another with PyQt3. The easiest way to do the dragging would appear to be
> with the QTextDrag object. So I convert my floating point numbers
> to a python string  via the 'struct' module 'pack' method - see
> line 30 in the 'startDrag' callback of the following script.
>
> However when I unpack in the
> 'dropEvent' callback I get incorrect values
> (1.0569533721655998e-307, 1.7246384989945063e-307) instead of
> the expected (1.2, 3.5). I'm obviously screwing up some
> ascii / unicode / binary translation thingy somewhere, as the
> methods work ok when I drag straight ascii text such as 'abcd_xyz'
> i.e. in that case the QTextDrag.decode call in line 19  will give
> text as 'abcd_xyz'.

Without looking into your code, have you considered using Decimals, and send 
the str() versions? Sure, they're not the fastest types in town, but unless 
you're not sending more than a few thousands of values on a decent system, 
they should do well without the usual float pains.

Pete



More information about the PyQt mailing list