[PyKDE] setIndicator in QProgressBar subclass

Torsten Marek shlomme at gmx.net
Wed Feb 2 22:54:26 GMT 2005


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hans-Peter Jansen schrieb:
| Hi Phil,
|
| here's an example from the Practical QT book from Kalle Dalheimer and
| Jesper Pedersen, where behaviour differs between C++ and Python.
|
| In the native version, a string will be displayed in the progressbar,
| shown with setIndicator(), unlike in the Python version.
|
| How can setting a QString reference variable work from within Python?
| I can send you the C++ version, if you like..
|
| TIA,
| Pete

Hello Peter,

you are rebinding the variable indicator. This destroys the reference which you
get from Qt. In C++, operator= of QString is overloaded and the instance is not
destroyed. Just modify the instance, exchange

indicator = "Measuring..."

with

indicator.truncate(0)
indicator +=  "Measuring..."

Then it works for me. Although I wonder why
indicator = time.toString()
does not destroy the reference, too.


greetings

Torsten
- --
Torsten Marek <shlomme at gmx.net>
ID: A244C858 -- FP: 1902 0002 5DFC 856B F146  894C 7CC5 451E A244 C858
Keyserver: subkeys.pgp.net

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFCAVoifMVFHqJEyFgRAoOgAJ9ScmDuzTuo10n/1ZSWgp/UQWjwfgCeM6Ew
LQjceAz7YNOpJCx9Cg3yEvc=
=MipK
-----END PGP SIGNATURE-----




More information about the PyQt mailing list