Just wanted to close this off with the two different solutions I eventually came up with:
First option - use EvevntFilter()
The code I used is based on the following reference:
qt-fluid.zip
Second option was to subclass a widget and rewrite its mouse event functions:
class dispFrame
: public QFrame{
Q_OBJECT
public:
explicit dispFrame
(QWidget* parent
= 0, Qt
::WindowFlags f
= 0);
~dispFrame(){}
protected:
/* PIP frame*/
int MouseX;
int MouseY;
private:
};
{
MouseX = evt->x();
MouseY = evt->y();
}
{
int newX = this->x() - (MouseX - evt->x());
int newY = this->y() - (MouseY - evt->y());
this->setGeometry(newX, newY, this->width(), this->height());
}
class dispFrame : public QFrame
{
Q_OBJECT
public:
explicit dispFrame(QWidget* parent = 0, Qt::WindowFlags f = 0);
~dispFrame(){}
protected:
/* PIP frame*/
int MouseX;
int MouseY;
private:
void mousePressEvent(QMouseEvent *);
void mouseMoveEvent(QMouseEvent *);
};
void dispFrame::mousePressEvent(QMouseEvent *evt)
{
MouseX = evt->x();
MouseY = evt->y();
}
void dispFrame::mouseMoveEvent(QMouseEvent *evt)
{
int newX = this->x() - (MouseX - evt->x());
int newY = this->y() - (MouseY - evt->y());
this->setGeometry(newX, newY, this->width(), this->height());
}
To copy to clipboard, switch view to plain text mode
Bookmarks