Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    [SOLVED] Implementing draggable windows

    General and Desktop
    2
    4
    751
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • N
      nicky j last edited by

      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!

      1 Reply Last reply Reply Quote 0
      • Q
        qxoz last edited by

        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();
        }
        }@

        1 Reply Last reply Reply Quote 0
        • N
          nicky j last edited by

          Figured it out. Thanks!

          1 Reply Last reply Reply Quote 0
          • Q
            qxoz last edited by

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

            1 Reply Last reply Reply Quote 0
            • First post
              Last post