![]() |
Blamite Game Engine - Keystone
00402.09.29.23.0627.blamite
A library that enables the use of Qt in Blamite's editing tools.
|
Class used for the drag container's grip widget. More...
#include <drag_container.h>
Public Member Functions | |
grip_frame () | |
void | paintEvent (QPaintEvent *event) override |
Class used for the drag container's grip widget.
Typically, we would use a QGraphicsView in order to have a widget that just displays an image. And in most cases, it's sufficient. However, because we need this widget to be interactive - that is, the user must be able to click and drag it - we end up having to use a QFrame instead.
Turns out, because a QGraphicsView has its own interactive behavior (in the form of dragging the image within it), trying to listen for both mouse clicks along with mouse movement - both of which are absolutely a requirement for the drag and drop behavior - is impossible. What happens instead is that no events are fired until the mouse is released, meaning that we wouldn't be able to update the widget while being dragged (or even properly detect if it was being dragged).
So, instead, we use a QFrame - but of course, you can't simply use stylesheets or anything built-in to apply a background image to a QFrame. Even putting a QGraphicsView inside of it doesn't work as it has the same issues as using a QGraphicsView by itself.
The only way to resolve this was to create a separate class that implements QFrame, and override the paintEvent()
method - and through that event, draw the background image used as the grip texture.
Yes, it's annoying. But yes, it works perfectly fine.
grip_frame::grip_frame | ( | ) |
|
override |