Qt 4: Move window without title bar

Try this to move the window manually:

void PopupWindow::mousePressEvent(QMouseEvent *event){
    mpos = event->pos();
}

void PopupWindow::mouseMoveEvent(QMouseEvent *event){
    if (event->buttons() & Qt::LeftButton) {
        QPoint diff = event->pos() - mpos;
        QPoint newpos = this->pos() + diff;

        this->move(newpos);
    }
}

And declare QPoint mpos somewhere.

Leave a Comment

tech