Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Draggable frame widget
Forum Update on Monday, May 27th 2025

Draggable frame widget

Scheduled Pinned Locked Moved Unsolved General and Desktop
c++qt6frame
2 Posts 2 Posters 410 Views
  • 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.
  • E Offline
    E Offline
    ELEMENTICY
    wrote on 14 Apr 2021, 09:58 last edited by
    #1

    How do i make Draggable frame widget in C++
    This is the ui i created in ui_desktop.h

    window = new QWidget(centralwidget);
            window->setObjectName(QString::fromUtf8("window"));
            window->setGeometry(QRect(200, 110, 841, 471));
            window->setMouseTracking(false);
            window->setAcceptDrops(true);
            window->setStyleSheet(QString::fromUtf8("background-color: whitesmoke;"));
            window_bar = new QWidget(window);
            window_bar->setObjectName(QString::fromUtf8("window_bar"));
            window_bar->setGeometry(QRect(0, 0, 841, 31));
            window_bar->setStyleSheet(QString::fromUtf8("background-color: white;"));
            window_title = new QLabel(window_bar);
            window_title->setObjectName(QString::fromUtf8("window_title"));
            window_title->setGeometry(QRect(10, 4, 141, 20));
            window_title->setStyleSheet(QString::fromUtf8("color: black;"));
    

    I want to do if the user dragged window_bar,you can move the whole window frame

    Please help me,
    thanks..

    Qt version: 6.0.1

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 14 Apr 2021, 18:48 last edited by
      #2

      Hi
      Well you override the mouse functions and make it happen.

      virtual void mousePressEvent( QMouseEvent *e );
      virtual void mouseMoveEvent( QMouseEvent *e );
      virtual void mouseReleaseEvent( QMouseEvent *e );
      

      have a look here
      https://gist.github.com/mnafees/10003130

      1 Reply Last reply
      1

      1/2

      14 Apr 2021, 09:58

      • Login

      • Login or register to search.
      1 out of 2
      • First post
        1/2
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved