[PyKDE] qwidget.eventFilter()
Aljosa Mohorovic
aljosa at revolucija.hr
Mon Jun 5 18:59:44 BST 2006
1. i have images.qrc > images.py imported 'import images' but
QIcon(':/images/rotate_left_over.png') and
QIcon(':/images/rotate_left.png') have no effect - code below.
QIcon(':/images/rotate_left.png') should work because
/images/rotate_left.png is used in designer from images.qrc resource
and is shown in application if i don't use eventFilter.
my guess is that i should change
QIcon(':/images/rotate_left_over.png') into something similar but i
don't know what.
2. i'm actually trying to capture mouse over/out events so i can
change qpushbutton icon on mouseOver and change some text elsewhere in
application.
# PyQt4-gpl-4.0beta1-Py2.4-Qt4.1.2.exe
# this method is part of object instance "a"
def eventFilter(self, obj, event):
if obj == ui.rotate_left:
if ui.rotate_left.underMouse():
ui.rotate_left.setIcon(QIcon(':/images/rotate_left_over.png'))
else:
ui.rotate_left.setIcon(QIcon(':/images/rotate_left.png'))
return False
ui.rotate_left.installEventFilter(a)
this (under 2.) works but i'm not sure this is the right way to do it,
probably not.
Aljosa Mohorovic
More information about the PyQt
mailing list