[Qt-interest] Resize Frameless Widget Challenge
Raja Rokkam
rokkamraja at gmail.com
Thu Jun 24 16:22:08 CEST 2010
Hi All,
I tried to implement the resize of a frameless widget by capturing the
mouseMoveEvent:
void testRegionSharingWindow::mouseMoveEvent( QMouseEvent *evt )
{
moveOffsetNew = this->mapFromGlobal(evt->globalPos());
if( evt->buttons() == Qt::LeftButton )
{
if( ( evt->globalX() > ( this->geometry().bottomRight().x() - 150 )
) && ( evt->globalY() > ( this->geometry().bottomRight().y() - 150 ) ) )
{
int x = moveOffsetNew.x() - moveOffset.x() +
geometry().bottomRight().x();
int y = moveOffsetNew.y() - moveOffset.y() +
geometry().bottomRight().y();
int width = moveOffsetNew.x() - moveOffset.x() +
geometry().width();
int height = moveOffsetNew.y() - moveOffset.y() +
geometry().height();
this->setGeometry( x, y, width, height );
evt->accept();
}
else
{
move( evt->globalPos() - dragging_position );
evt->accept();
}
}
}
void testRegionSharingWindow::mousePressEvent( QMouseEvent *evt )
{
if( evt->button() == Qt::LeftButton )
{
moveOffset = this->mapFromGlobal(evt->globalPos());
invertedMoveOffset = this->rect().bottomRight() - moveOffset;
orig_position = geometry().topLeft();
evt_position = evt->globalPos();
dragging_position = evt->globalPos() - frameGeometry().topLeft();
evt->accept();
}
}
However, I see a line: *Warning:* Calling setGeometry() inside
resizeEvent<http://doc.qt.nokia.com/4.6/qwidget.html#resizeEvent>()
or moveEvent <http://doc.qt.nokia.com/4.6/qwidget.html#moveEvent>() can lead
to infinite recursion.
How can I go about the resizing as the chunk of code is not working as
expected ?
Thanks,
Raja.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100624/a999d508/attachment.html
More information about the Qt-interest-old
mailing list