PDA

View Full Version : Move Frames



Slewman
9th October 2009, 14:17
I have an application with a settings frame with different toggle buttons and labels and such... I want the user to be able to click anywhere on the frame and be able to relocate the frames position within the application with a move of the mouse.

I have looked into the mouseMoveEven but i am slightly confused, mostly because i am new to QT and semi-new to c++

can anyone give me any tips? help is greatly appreciated.

thanks

Slewman
9th October 2009, 16:06
let me show what i have and what happens, maybe someone can just give me a small tip as to how i can fix my code.




void WeaponsInterface::mousePressEvent(QMouseEvent* event)
{
event->accept(); // do not propagate
offset = event->pos();
}

void WeaponsInterface::mouseMoveEvent(QMouseEvent* event)
{
event->accept(); // do not propagate
move(mapToParent(event->pos() - offset));
}

void WeaponsInterface::mouseReleaseEvent(QMouseEvent* event)
{
event->accept(); // do not propagate
offset = QPoint();
}


so, this code does succeed in moving a frame in my application, the only problem is that it moves the parent frame, of all my components in my application. How can i specify it to only move the frame i am selecting, and not move the frame i am selecting's parent?

Slewman
13th October 2009, 14:03
still having same problems... i figured taking out the "moveToParent()" would possibly make it only move the frame i wanted, but when i remove the moveToParent() it does the same this except when the whole parent frame moves it is very shaky and not a smooth move...

anyone have any suggestions?