Mouse cursor changes to 'resize' on inner widgets



  • Hi,
    I have a GUI, that has a tab widget.
    On every tab there is a tree view and a editor widget.
    Editor is shown only when I hover over an item, in the tree view.

    Sometimes when I hover over the tree views empty space, or editors push buttons, the mouse cursor changes from the normal arrow, to the horizontal resize arrows (horizontal line with an arrow on each side).
    It happens only from time to time.

    My main window is frameless (Qt::FramelessWindowHint) and I do the resizing manualy. I've set breakpoints on the code, where I change the mouse coursor to the resize one, but It looks like it's not related to my code (doesn't execute this code when the problem occurs).

    I can supply all the code you need, but its a complex application and I'm not sure where to look.

    Could someone give me some hints on where to look for the cause of the problem?

    One dependency I found is, that when I do something else in a seperate program, and then hover the mouse over the app.

    What helps is to switch vews (from one tab in a tab widget, to another, and then back)


  • Qt Champions 2016

    Hi
    Can it be a hidden splitter ?

    If you // out any use of setCursor, does it still happen?



  • @mrjj thank you for your answer.

    I do not have any splitters in those widgets.
    I did not try to comment out the setCursor, but I did place a breakpoint on the code, where I change the cursor to a resize cursor.

    I will try to comment out setCursor.


  • Qt Champions 2016

    @michalos

    I cant think of any other widgets (besides as a window) that would use the
    resize cursor. alt text



  • @mrjj said in Mouse cursor changes to 'resize' on inner widgets:

    nt think of any other widgets (besides as a window) that

    I will do some more testing, because the problem only happens form time to time, but it seems, that code from a class I borowed from github seems to be the problem:

    void FrameLess::updateCursorShape(const QPoint &pos) {
        if (_parent->isFullScreen() || _parent->isMaximized()) {
            if (_cursorchanged) {
                _parent->unsetCursor();
            }
            return;
        }
        if (!_leftButtonPressed) {
            calculateCursorPosition(pos, _parent->frameGeometry(), _mouseMove);
            _cursorchanged = true;
            if (_mouseMove.testFlag(Edge::Top) || _mouseMove.testFlag(Edge::Bottom)) {
                _parent->setCursor(Qt::SizeVerCursor);
            } else if (_mouseMove.testFlag(Edge::Left) || _mouseMove.testFlag(Edge::Right)) {
                _parent->setCursor(Qt::SizeHorCursor);
            } else if (_mouseMove.testFlag(Edge::TopLeft) || _mouseMove.testFlag(Edge::BottomRight)) {
                _parent->setCursor(Qt::SizeFDiagCursor);
            } else if (_mouseMove.testFlag(Edge::TopRight) || _mouseMove.testFlag(Edge::BottomLeft)) {
                _parent->setCursor(Qt::SizeBDiagCursor);
            } else if (_cursorchanged) {
                _parent->unsetCursor();
                _cursorchanged = false;
            }
        }
    }
    
    

    When I comment out the _parent->setCursor() the problem stopped.

    Any idea why the coursor only locks it selve on the Qt::SizeHorCursor?

    
    void FrameLess::mouseHover(QHoverEvent *e) {
        updateCursorShape(_parent->mapToGlobal(e->pos()));
    }
    
    void FrameLess::mouseLeave(QEvent *e) {
        if (!_leftButtonPressed) {
            _parent->unsetCursor();
        }
    }
    void FrameLess::mouseMove(QMouseEvent *e) {
        if (_leftButtonPressed) {
            if (_dragStart) {
                _parent->move(_parent->frameGeometry().topLeft() + (e->pos() - _dragPos));
            }
    
            if (!_mousePress.testFlag(Edge::None)) {
                int left = _rubberband->frameGeometry().left();
                int top = _rubberband->frameGeometry().top();
                int right = _rubberband->frameGeometry().right();
                int bottom = _rubberband->frameGeometry().bottom();
                switch (_mousePress) {
                case Edge::Top:
                    top = e->globalPos().y();
                    break;
                case Edge::Bottom:
                    bottom = e->globalPos().y();
                    break;
                case Edge::Left:
                    left = e->globalPos().x();
                    break;
                case Edge::Right:
                    right = e->globalPos().x();
                    break;
                case Edge::TopLeft:
                    top = e->globalPos().y();
                    left = e->globalPos().x();
                    break;
                case Edge::TopRight:
                    right = e->globalPos().x();
                    top = e->globalPos().y();
                    break;
                case Edge::BottomLeft:
                    bottom = e->globalPos().y();
                    left = e->globalPos().x();
                    break;
                case Edge::BottomRight:
                    bottom = e->globalPos().y();
                    right = e->globalPos().x();
                    break;
                }
                QRect newRect(QPoint(left, top), QPoint(right, bottom));
                if (newRect.width() < _parent->minimumWidth()) {
                    left = _parent->frameGeometry().x();
                } else if (newRect.height() < _parent->minimumHeight()) {
                    top = _parent->frameGeometry().y();
                }
                _parent->setGeometry(QRect(QPoint(left, top), QPoint(right, bottom)));
                _rubberband->setGeometry(QRect(QPoint(left, top), QPoint(right, bottom)));
            }
        } else {
            updateCursorShape(e->globalPos());
        }
    }
    

  • Qt Champions 2016

    Hi
    Well it sounds like sometimes, you experience a situation that is not properly
    covered by the logic and maybe _cursorchanged or _leftButtonPressed is not
    in expected state and the cursor is not reset.

    This one
    https://github.com/dfct/TrueFramelessWindow `?



  • @mrjj

    I will debug the code some more and try to find the conditions this happens.

    as to the code, it's not the TrueFramelessWindow. I've tried to find it, but it's as if someone removed it..


  • Qt Champions 2016

    @michalos
    super.
    I would insert
    qDebug() in a few places so I could run the app with no break points and still see what is going on.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.