Draggable frame widget
Unsolved
General and Desktop
-
How do i make Draggable frame widget in C++
This is the ui i created in ui_desktop.hwindow = 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 wholewindow
framePlease help me,
thanks..Qt version: 6.0.1
-
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