Skip to content
  • 0 Votes
    3 Posts
    472 Views
    D

    I have the same problem, looking for someone to answer it.

  • 0 Votes
    4 Posts
    752 Views
    EmrecpE

    @SGaist
    removing self.parent = parent did not help. Problem still continues.

  • 0 Votes
    4 Posts
    2k Views
    mrjjM

    @wrekler
    ok. Im not sure what system buttons are.
    But yes, its most likely there are bugs as its pretty involving across
    platforms to support such decoration less window.

  • 0 Votes
    2 Posts
    5k Views
    Diego DonateD

    I have changed the structure, I have used a QQuickWidget with a QML inside, and now I have what I wanted. Here is my code in case anyone needs something similar

    main.cpp

    ... MovableWidget *view = new MovableWidget; view->setSource(QUrl("qrc:/Test.qml")); view->setWindowFlags(Qt::FramelessWindowHint); view->show(); ...

    Test.qml

    import QtQuick 2.0 Rectangle { id: myWindow width: 500; height: 500 color: "yellow" Rectangle { anchors.centerIn: parent width: 200; height: 200 color: "red" } }

    MovableWidget.cpp

    #include "movableWidget.h" #include <QMouseEvent> // ************************************************** ************************** MovableWidget::MovableWidget(QWidget *parent) : QQuickWidget(parent), m_previousPos(0,0) { installEventFilter(this); } // ************************************************** ************************** bool MovableWidget::eventFilter(QObject *obj, QEvent *event) { if (event->type() == QEvent::MouseButtonPress) { m_previousPos = QCursor:os(); } else if (event->type() == QEvent::MouseMove) { QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event); if(mouseEvent->buttons() == Qt::LeftButton) { QPoint offset = m_previousPos - QCursor:os(); m_previousPos = QCursor:os(); move(pos() - offset); } } return false; }
  • 0 Votes
    4 Posts
    13k Views
    mrjjM

    @the_
    Yep its a nice few liners and not really dirty as sizegrip is made for such task so
    its not abuse or anything :)
    But sometimes having the grip there can be issue.

  • 0 Votes
    7 Posts
    5k Views
    IMAN4KI

    Ok.
    It might get better in the future !

    If you wan to get ride of QGraphicsDropShadowEffect :

    void drawShadow(QPainter &_painter, qint16 _margin, qreal _radius, QColor _start, QColor _end, qreal _startPosition, qreal _endPosition0, qreal _endPosition1, qreal _width, qreal _height) { _painter.setPen(Qt::NoPen); QLinearGradient gradient; gradient.setColorAt(_startPosition, _start); gradient.setColorAt(_endPosition0, _end); // Right QPointF right0(_width - _margin, _height / 2); QPointF right1(_width, _height / 2); gradient.setStart(right0); gradient.setFinalStop(right1); _painter.setBrush(QBrush(gradient)); _painter.drawRoundRect(QRectF(QPointF(_width - _margin*_radius, _margin), QPointF(_width, _height - _margin)), 0.0, 0.0); // Left QPointF left0(_margin, _height / 2); QPointF left1(0, _height / 2); gradient.setStart(left0); gradient.setFinalStop(left1); _painter.setBrush(QBrush(gradient)); _painter.drawRoundRect(QRectF(QPointF(_margin *_radius, _margin), QPointF(0, _height - _margin)), 0.0, 0.0); // Top QPointF top0(_width / 2, _margin); QPointF top1(_width / 2, 0); gradient.setStart(top0); gradient.setFinalStop(top1); _painter.setBrush(QBrush(gradient)); _painter.drawRoundRect(QRectF(QPointF(_width - _margin, 0), QPointF(_margin, _margin)), 0.0, 0.0); // Bottom QPointF bottom0(_width / 2, _height - _margin); QPointF bottom1(_width / 2, _height); gradient.setStart(bottom0); gradient.setFinalStop(bottom1); _painter.setBrush(QBrush(gradient)); _painter.drawRoundRect(QRectF(QPointF(_margin, _height - _margin), QPointF(_width - _margin, _height)), 0.0, 0.0); // BottomRight QPointF bottomright0(_width - _margin, _height - _margin); QPointF bottomright1(_width, _height); gradient.setStart(bottomright0); gradient.setFinalStop(bottomright1); gradient.setColorAt(_endPosition1, _end); _painter.setBrush(QBrush(gradient)); _painter.drawRoundRect(QRectF(bottomright0, bottomright1), 0.0, 0.0); // BottomLeft QPointF bottomleft0(_margin, _height - _margin); QPointF bottomleft1(0, _height); gradient.setStart(bottomleft0); gradient.setFinalStop(bottomleft1); gradient.setColorAt(_endPosition1, _end); _painter.setBrush(QBrush(gradient)); _painter.drawRoundRect(QRectF(bottomleft0, bottomleft1), 0.0, 0.0); // TopLeft QPointF topleft0(_margin, _margin); QPointF topleft1(0, 0); gradient.setStart(topleft0); gradient.setFinalStop(topleft1); gradient.setColorAt(_endPosition1, _end); _painter.setBrush(QBrush(gradient)); _painter.drawRoundRect(QRectF(topleft0, topleft1), 0.0, 0.0); // TopRight QPointF topright0(_width - _margin, _margin); QPointF topright1(_width, 0); gradient.setStart(topright0); gradient.setFinalStop(topright1); gradient.setColorAt(_endPosition1, _end); _painter.setBrush(QBrush(gradient)); _painter.drawRoundRect(QRectF(topright0, topright1), 0.0, 0.0); // Widget _painter.setBrush(QBrush("#FFFFFF")); _painter.setRenderHint(QPainter::Antialiasing); _painter.drawRoundRect(QRectF(QPointF(_margin, _margin), QPointF(_width - _margin, _height - _margin)), _radius, _radius); }

    drawShadow(painter, 10, 2.0, QColor(120, 120, 120, 32), QColor(255, 255, 255, 0), 0.0, 1.0, 0.6, width(), height());
    don't forget setAttribute(Qt::WA_TranslucentBackground);
    Final Resualt : https://onedrive.live.com/?cid=8882d1e3bc0f61ab&id=8882D1E3BC0F61AB!7415&authkey=!AH66ZieCJDqvXhk

  • 0 Votes
    19 Posts
    14k Views
    W

    I found very usefull this class, I added some code to handle correctly a maximized FrameLess Widget.
    In

    void FrameLess::mouseMove(QMouseEvent *e) { if (_dragStart) { if (_parent->isMaximized()) { //this will handle correctly dragging when it is maximized maximizeWidth = _parent->width(); //maximizeWidth is an int attribute _parent->showNormal(); } if (_dragPos.x() > _parent->width()) _dragPos.setX((_parent->width()*_dragPos.x()) / maximizeWidth); _parent->move(e->globalX() - _dragPos.x(), e->globalY() - _dragPos.y()); } if (!_mousePress.testFlag(Edge::None) && !_parent->isMaximized() ) { //this prevent resizing if it is maximized [...]

    Now I'm wondering if there is a way to implement Windows 7/10 autosize function (the function when you drag a window on top/left/right/bottom edge of desktop and it will maximize/resize to half desktop size) on a frameless widget!

  • 1 Votes
    12 Posts
    4k Views
    bashtianB

    @Guy-Gizmo thank you very much for the answer, I will check it out, the click throu doesnt work at all on my mac, I will ttry to sort that out and see if I can combine both to achieve that effect.

  • 0 Votes
    1 Posts
    2k Views
    No one has replied