0

Basically I have a qlabel that I set an img.

self.QLabel.setPixMap(QtGui.QPixmap(image.jpg))

I enabled set mouse tracking and a mouse move event so I can get the coordinates of my mouse when I hover over the images.

self.QLabel.setMouseTracking(True)
self.QLabel.mouseMoveEvent = self.hoverFunction

In the hover Function I get the x coordinate of my mouse over the image.

posX=e.x()

The image being displayed is part of a list of 100. I am then using the posX to pick a new image in the list of 100 and update the pixmap in the hover function.

self.QLabel.setPixMap(QtGui.QPixmap(newImage.jpg))

As of right now this is working but it is very slow. I want to be able to change the image fast as I move my mouse. Giving the illusion of scrubbing a video. But right now it skips around and updates slowly. Any tips?

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
cjaxx
  • 33
  • 7
  • Thanks for cleaning it up eyllanesc. – cjaxx May 25 '17 at 00:04
  • 1
    Don't create a new QPixmap each time. Create all 100 QPixmaps at startup then just `self.QLabel.setPixMap(self.pixmap_list[0])`. That should help some. You probably don't need to change the pixmap with every slight mouse movement either. You probably want to put some limits in. – justengel May 25 '17 at 00:21
  • Creating all the pixmaps speeds it up nicely when scrubbing the only bad thing is the application locks up when it creates the 100 pixmaps. Taking around 30seconds. – cjaxx May 25 '17 at 01:10
  • I read something about repaint is that something I should be using instead? – cjaxx May 25 '17 at 01:20
  • @cjaxx. The bottleneck is reading the image data from the storage device. It sounds like the image files must be quite large if it takes 30 seconds to read 100 of them - either that, or the read-speed of the storage device is somewhat slow. If the images were stored on an SSD, you could use multi-threading to read the files in parallel. But that is not a viable option with hard-disks - serial reading is the best that can be done. Maybe you should experiment with using lower-quality images, so that there is less data to read on start-up. – ekhumoro May 25 '17 at 16:22
  • Yes I noticed lower quality images are much faster – cjaxx May 25 '17 at 18:46

0 Answers0