Qt World Summit: Submit your Presentation


[SOLVED] Implementing draggable windows



  • Hello!

    I have been playing around with making frameless windows. When you remove the OS-given frame from a window, you lose the ability to drag the window around the screen. How can I reimplement this feature?

    Thanks!



  • Well you can implement something like this:
    @void Dialog::mouseMoveEvent(QMouseEvent *event)
    {
    if(event->buttons() & Qt::LeftButton)
    {
    this->move(event->globalPos() - cursorPos);
    }
    }

    void Dialog::mousePressEvent(QMouseEvent *event)
    {
    if(event->buttons() & Qt::LeftButton)
    {
    cursorPos = event->pos();
    }
    }@



  • Figured it out. Thanks!



  • You're welcome. Don't forget mark thread as solved :) .


Log in to reply