Hi Gunnar,

yeah, it helped. Thank you! When is qt jambi 4.5 releasing? Q3-4 of this 
year?

Dawid
> Dawid Sip wrote:
>> Hi,
>> im playing alot with GraphicsView these days and I came accross a 
>> following problem. I have a reimplemented QGraphicsView class where i 
>> interecept the keyboardkeys:
>>
>>         protected  void keyPressEvent(QKeyEvent event){
>>             event.accept();
>>             if(event.key()==Qt.Key.Key_Control.value())
>>                 this.setDragMode(DragMode.ScrollHandDrag);
>>                        super.keyPressEvent(event);
>>         }
>>                protected void keyReleaseEvent(QKeyEvent event){
>>             event.accept();
>>             if(event.key()==Qt.Key.Key_Control.value())
>>                 this.setDragMode(DragMode.NoDrag);
>>                        super.keyReleaseEvent(event);
>>         }
>>
>> I do this to achieve the following behaviour. When i press the ctrl 
>> key i want the DragMode to change to ScrollHandDrag. Then, when I 
>> press the left mouse key i can drag the viewport(scroll), when I'm 
>> done scrolling i release the left mouse button afterwhich i release 
>> the ctrl key. All works ok. But if I hit the following sequence of 
>> keys, the behavior will break. I press the ctrl key and then press 
>> the left mouse key, drag the view port and when I'm done I first 
>> release the ctrl key and then release the left mouse key. When I then 
>> want to repeat such scroll action the view port is drag as soon as I 
>> hit ctrl key, and not even tougch the mouse keys... What is wrong? 
>> Some ideas?
>
> Hi Dawid,
>
> This is caused by a bug in QGraphicsView. This will be fixed in Qt 
> 4.5, and in the meantime you can work around this by "faking" a 
> mouseRelease prior to unsetting the drag mode:
>
> protected void keyReleaseEvent(QKeyEvent event){
>     event.accept();
>     if(event.key()==Qt.Key.Key_Control.value()) {
>         // Fake a mouse release...
>         QEvent e = new QMouseEvent(QEvent.Type.MouseButtonRelease,
>                                    new QPoint(0, 0),
>                                    Qt.MouseButton.LeftButton,
>                                    new Qt.MouseButtons(),
>                                    new Qt.KeyboardModifiers());
>        QApplication.sendEvent(viewport(), e);
>        this.setDragMode(DragMode.NoDrag);
>     }
>     super.keyReleaseEvent(event);
> }
>
> Hope this helps.
>
> best regards,
> Gunnar
>

_______________________________________________
Qt-jambi-interest mailing list
[email protected]
http://lists.trolltech.com/mailman/listinfo/qt-jambi-interest

Reply via email to