KeyPressEvent while dragging
-
-
Are those items come from another window/separate widget, or table widget is a child for QGLWidget?
If QGLWidget loses focus, then window messages, like keyboard ones will go to someone else, and then you drop on QGLWidget and it gains focus again. That may happen. -
They are in the same window, but as separate widgets. And I also call setFocus(), and grabKeyboard() on dragEnterEvent(). This gives QGLWidget focus, but keyborad is not responding.
I solve this problem with reprograming this functionality with enter/leaveEvent and mousePress,Release and move events.
Thanks a lot for your time anyway:)
-
If you want to drag and drop items from tableWidget to QGLWidget u need to override the following methods .
-
Table Widget:
@protected:
void dragEnterEvent(QDragEnterEvent *event);
void dragMoveEvent(QDragMoveEvent *event);
void dropEvent(QDropEvent *event);
void startDrag(Qt::DropActions supportedActions);@ -
QGLWidget
@protected:
void dragEnterEvent(QDragEnterEvent *event);
void dragMoveEvent(QDragMoveEvent *event);
void dropEvent(QDropEvent *event);
void mousePressEvent(QMouseEvent *event);
void paintEvent(QPaintEvent *event);@
The following examples in the documentation gives an idea about how the drag and drop can be implemented:
- Draggable Icons Example.
- Drag and Drop Puzzle Example.
I have also done something similar to what you require but with a listView and a QWidget. If u need any further help feel free to ask :)
-
-
I have no problem with implementing it that way. But yesterday I ´ve found this in Qt Doc on QDrag->exec()
On Windows, the Qt event loop is blocked during the operation.So i think, i wouldn't be albe to use keyboard input during the drag and drop operation.