ich möchte innerhalb des QMdiAreas ein "fenster" zur verfügung stellen,
welches der user bewegen kann. den windows-typischen "rahmen" möchte
ich nicht haben.
Nun stelle ich mein QMdiSubWindow wie folgt zusammen:
Code: Alles auswählen
QMdiSubWindow* mMdiSubWindow = new QMdiSubWindow(this->mdiArea, Qt::FramelessWindowHint);
mMdiSubWindow->setWidget(mCustomWidget);
this->mdiArea->addSubWindow(mMdiSubWindow);
this->mdiArea->setActiveSubWindow(mMdiSubWindow);
setCentralWidget(this->mdiArea);
auf dem QLabel führe ich ein installEventFilter(this) aus. (wobei this mCustomWidget ist)
in der methode eventFilter von mCustomWidget leite ich den QMouseEvent weiter an
mousePressEvent, mouseMoveEvent und mouseReleaseEvent.
ich kann mit dem QLabel das QMdiSubWindow innerhalb von QMdiArea verschieben.
Code: Alles auswählen
if(moving) {
QObject* qParent = this->parent();
QMdiSubWindow* mSubWindow = qobject_cast<QMdiSubWindow*>(qParent);
QPoint qPoint = mSubWindow->mapToParent(event->pos() - offset);
mSubWindow->move(qPoint);
QRect& qRect = const_cast<QRect&>(mSubWindow->geometry());
qRect.setX(qPoint.x());
qRect.setY(qPoint.y());
}
zurück zum ursprungspunkt (also vom QMdiArea, als parent, aus gesehen auf 0,0).
ich weiß nicht, wie ich es dem QMdiSubWindow begreiflich machen kann, daß sich seine
position geändert hat.
für tipps wäre ich euch sehr dankbar.
gruss
QuornJulio