Skip to content
This repository was archived by the owner on Aug 31, 2026. It is now read-only.

Commit 0774084

Browse files
committed
fix: Add mouse propogation to qml chat in qquickwidget
1 parent 282f48d commit 0774084

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

ChatView/ChatWidget.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include "ChatWidget.hpp"
55

66
#include <QApplication>
7+
#include <QMouseEvent>
78
#include <QQmlContext>
89
#include <QQmlEngine>
910
#include <QQuickItem>
@@ -38,6 +39,8 @@ ChatWidget::ChatWidget(
3839
setResizeMode(QQuickWidget::SizeRootObjectToView);
3940
setFocusPolicy(Qt::StrongFocus);
4041

42+
setAttribute(Qt::WA_NoMousePropagation, true);
43+
4144
if (registerOwnContext) {
4245
auto ideContext = new Core::IContext{this};
4346
ideContext->setWidget(this);
@@ -53,6 +56,14 @@ void ChatWidget::focusInEvent(QFocusEvent *event)
5356
QMetaObject::invokeMethod(rootObject(), "focusInput");
5457
}
5558

59+
void ChatWidget::mousePressEvent(QMouseEvent *event)
60+
{
61+
if (!hasFocus())
62+
setFocus(Qt::MouseFocusReason);
63+
64+
QQuickWidget::mousePressEvent(event);
65+
}
66+
5667
void ChatWidget::clear()
5768
{
5869
QMetaObject::invokeMethod(rootObject(), "clearChat");

ChatView/ChatWidget.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class ChatWidget : public QQuickWidget
4242

4343
protected:
4444
void focusInEvent(QFocusEvent *event) override;
45+
void mousePressEvent(QMouseEvent *event) override;
4546
};
4647

4748
} // namespace QodeAssist::Chat

0 commit comments

Comments
 (0)