How do you create a custom QCursor in Python Qt?

Steegg at gmail.com Steegg at gmail.com
Thu Dec 8 09:12:40 EST 2005


Thanks Phil,

Good idea, I had failed to notice these code examples and been
struggling the "qt3" examples from pyqtsrc.tgz for months.

So, I found my mistake, I was using a 8*8 bitmap, I have now corrected
it and use a 16*16 bitmap (which is the standard size on Mac OS X) read
in from a "PNG" file created in Photoshop in bitmap mode and it works
just great.

I failed to read the C++ documentation for Qt closely enough where it
states:

 Valid cursor sizes depend on the display hardware (or the underlying
window system). We recommend using 32x32 cursors, because this size is
supported on all platforms. Some platforms also support 16x16, 48x48
and 64x64 cursors.

As a Python novice I had simply taken the bitmap that was available in
the documentation for Qbitmap, which happens to be an 8*8 bitmap.


Interestingly on my G5 iMac Mac OS X 10.4.3 running Python 2.4.1 &
Qt3.3.5 QCursors of both 16*16 & 32*32 works perfectly; whereas on my
G4 Powerbook Mac OS X 10.4.2 running the same Python 2.4.1 & Qt3.3.5, a
16*16 QCursor works but a 32*32 QCursor doesn't, but since there are no
error messages that is all that I can report. Interesting!

I have also tested my code on a PC, which supports 32*32 but does not
support
16*16.

    -------------------

I have two auxiliary questions if anybody can help me.

1: When I click on a button the cursor does not change immediately, the
cursor only actually gets re-drawn when I physically move the mouse.
Is there a way to get it to update instantaneously?
After "setCursor() I call "repaint(True)"  but this does not have the
desired effect.

    def bitmap(self):
        self.setCursor(self.inlineBitmapCursor)
        self.repaint(True)


2: The cursor that I want to customise is the wait cursor; under Mac OS
X this is an animated cursor displaying a wristwatch with hands that go
around?
So my question is where do I find the code that produces this effect,
is it written in C++ or Python and how can I imitate it?

Steve




More information about the Python-list mailing list