I currently have a QSlider that scrolls through frames of image data using the mouse. I would like to be able to use the arrow keys to scroll through a single step (one frame).
This is my current sliderMoved code:
def sliderMoved(self,val):
"""
retrieves the data array for the index value specified by the slider
"""
if self.fileheader is None:
print "[DEBUG] change_image_index(): self.fileheader is None"
return
idx=val
self.x=idx
frame=self.fileheader.frameAtIndex(idx)
image=scipy.ndimage.filters.maximum_filter(frame.data, size=5)
self.image.setImage(image, scale=((10.28/512),(2.486/96)))
print self.image.imageItem.pixelSize()
def keyPressEvent(self, event):
if event.key()==Qt.Key_Right:
frame=self.fileheader.frameAtIndex(idx+1)
To connect the slider to the events, I just use:
self.slider.sliderMoved.connect(self.sliderMoved)
self.slider.sliderMoved.connect(self.keyPressEvent)
The arrow key moves the slider, but it does not cause the image to skip frames... I know I'm missing something silly here...