[PyQt] Where to start
diego at cortassa.net
Fri Jun 3 15:24:55 BST 2011
>> I am trying to do is display an image, and then using drag-selection
>> select a sub-image for later processing. Eventually I want to be
>> to select multiple regions and tag each region for appropruate back
>> processing, but for now just being able to select one sub-image
>> be good. I can display an image, but don't know how to implement
>> drag-selection (think it is also know as rubber band selection). I
>> assuming I will need to write some mouse-callbacks or something. My
>> search-fu has failed me and I haven't been able to find any examples
>> study. Can someone give me any pointers to which widgets I should be
>> using and perhaps where to find a sample program I can study.
> There didn't seem to be much in the PyQt examples to show this - the
> itemviews/chart example does use QRubberBand to allow the user to
> data, but that's not the best example to learn this technique from.
> I quickly wrote an example that does part of what you want:
> http://www.diotavelli.net/PyQtWiki/Selecting_a_region_of_a_widget 
> Hope this helps,
thanks for your example! I was experimeting on QRubberBand too and it
helped me a lot.
I tried your code myself but I found a small bug that confused me at
def mouseMoveEvent(self, event):
if event.button() == Qt.LeftButton:
you check if the value retured by QMouseEvent.button() is Qt.LeftButton
states that "the returned value is always Qt.NoButton for mouse move
events."; the code in mouseMoveEvent will never be executed and the
rubber band will not work.
Il messaggio e' stato analizzato alla ricerca di virus o
contenuti pericolosi da MailScanner, ed e'
risultato non infetto.
More information about the PyQt