PDA

View Full Version : Move Frameless Dialog



deepal_de
25th May 2011, 09:01
Hello,

Any know how to move a Frameless QDialog?
And can you please post a example code..

Note:
the QDialog i have is filled with Qwidgets.so mouse click event will set the focus on to Qwidget. not the Qdialog..

Thank you..

joyer83
25th May 2011, 09:55
Use this to move the dialog around:

void QWidget::move ( int x, int y )

high_flyer
25th May 2011, 10:07
the QDialog i have is filled with Qwidgets.so mouse click event will set the focus on to Qwidget. not the Qdialog..
use an even filter.

deepal_de
25th May 2011, 12:02
thanks for the reply...



void QWidget::move ( int x, int y )

this not the kind of example i had in mind, but thanks anyway :)

here i have to calculate the mouse point offset know??
that means if the user click middle of the dialog,
i have to get the point of the mouse click and and mapToGloble,
get the difference between the mouse click point and the form location..
and do the math and then move the dialog...
for this i have to catch the mouse press event and release event know..

i was wondering if there is some other simple way to do this..
any built-in mechanism to help move frame-less dialogs??

joyer83
25th May 2011, 12:38
this not the kind of example i had in mind, but thanks anyway :)
You welcome, simple answer (for me) to a simple question. :)


here i have to calculate the mouse point offset know??
that means if the user click middle of the dialog,
i have to get the point of the mouse click and and mapToGloble,
get the difference between the mouse click point and the form location..
and do the math and then move the dialog...
for this i have to catch the mouse press event and release event know..

i was wondering if there is some other simple way to do this..
any built-in mechanism to help move frame-less dialogs??
Yes, I'm afraid that if you remove the borders and title bar you have to implement everything by yourself.
Easiest might be to create your own title bar as a widget and then reimplement the mouse event handlers of that widget. Or use the event filter instead of reimplementing.

high_flyer
25th May 2011, 12:40
No, you will have to implement it your self, and frame less windows, by definition are not meant to be moved (usually used for splash screens), since there is no way to "hold" them, since they don't have a frame.

deepal_de
26th May 2011, 04:56
Thanks for the reply's..... :)

deepal_de
6th June 2011, 08:35
int iXdeffarace = -1;
int iYdeffarance = -1;
bool b_mousePressed;

void mydialog::mousePressEvent ( QMouseEvent * event)
{
b_mousePressed = true;
QPoint qpMousePressedPoint = QCursor::pos();
QPoint qpApploc = this->pos();
iXdeffarace = qpMousePressedPoint.x() - qpApploc.x();
iYdeffarance = qpMousePressedPoint.y() - qpApploc.y();
}

//************************************************** ******
void mydialog::mouseReleaseEvent ( QMouseEvent * event )
{
b_mousePressed = false;
}

//************************************************** ******
void mydialog::mouseMoveEvent ( QMouseEvent * event )
{
if(b_mousePressed)
{
QPoint qpAppNewLoc( (QCursor::pos().x() - iXdeffarace) , (QCursor::pos().y() - iYdeffarance) );
this->setProperty("pos", qpAppNewLoc);
}
}