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. startSystemMove() and FramelessWindowHint on a QWidget: Can't trigger Windows Features like aerosnap

startSystemMove() and FramelessWindowHint on a QWidget: Can't trigger Windows Features like aerosnap

Scheduled Pinned Locked Moved Unsolved General and Desktop
qwidgetstartsystemmoveframelesswindowtitle baraero
2 Posts 2 Posters 572 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.
  • K Offline
    K Offline
    KKiranbay
    wrote on 24 Jan 2023, 07:16 last edited by
    #1

    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 :)

    1 Reply Last reply
    1
    • S Offline
      S Offline
      schrute
      wrote 10 days ago last edited by
      #2

      Were you able to figure this out?

      1 Reply Last reply
      0

      • Login

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