startSystemMove() and FramelessWindowHint on a QWidget: Can't trigger Windows Features like aerosnap
Unsolved
General and Desktop
-
Hello everyone,
I am using Qt 5.15.8 and I have a problem with startSystemMove():
I have a container class named WindowContainerWidget that inherits QWidget. It displays a custom title bar and shown a custom widget inside itself. I made this class so that I can have a custom title bar that is same on my app's windows.
Its constructor:
WindowContainerWidget::WindowContainerWidget(WindowContainerWidgetSetPropertiesData data, QWidget *parent) : QWidget(parent) { Qt::WindowFlags flags = this->windowFlags(); flags |= Qt::FramelessWindowHint; flags |= Qt::WindowStaysOnTopHint; this->setWindowFlags(flags); this->setAttribute(Qt::WA_NoSystemBackground); this->setAttribute(Qt::WA_TranslucentBackground); properties = data; setMainLayout(); this->installEventFilter(this); }
I get title of the window and the widget to be displayed inside the container using my WindowContainerWidgetSetPropertiesData.
I have implemented my eventFilter like this:
bool hvlsim::scenariouserinterface::WindowContainerWidget::eventFilter(QObject *obj, QEvent *event) { switch (event->type()) { case QEvent::MouseButtonPress: { QPoint pos = static_cast<QMouseEvent *>(event)->pos(); Qt::Edges edges; if (isResize(pos, edges)) { systemResize(edges); } else { systemMove(pos); } return true; } } return obj->event(event); }
And my systemMove():
systemMove(const QPointF &p) { if (p.x() > border && (p.x() < width() - border) && p.y() > border && p.y() < titleBar->height()) { this->windowHandle()->startSystemMove(); } }
I can't figure out why this doesn't trigger aerosnap features of Windows 10. Can anyone give me some insight? Thanks :)