Elaztek Developer Hub
Blamite Game Engine - Keystone  00402.09.29.23.0627.blamite
A library that enables the use of Qt in Blamite's editing tools.
grip_frame Class Reference

Class used for the drag container's grip widget. More...

#include <drag_container.h>

+ Inheritance diagram for grip_frame:
+ Collaboration diagram for grip_frame:

Public Member Functions

 grip_frame ()
 
void paintEvent (QPaintEvent *event) override
 

Detailed Description

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.

Todo:
Store the QImage used for the background, as this may end up constantly hitting the disk with the current approach.

Constructor & Destructor Documentation

◆ grip_frame()

grip_frame::grip_frame ( )
+ Here is the call graph for this function:

Member Function Documentation

◆ paintEvent()

void grip_frame::paintEvent ( QPaintEvent *  event)
override
+ Here is the call graph for this function:

The documentation for this class was generated from the following files: