Qt QML窗口防止焦点窃取
我正在用基于qml的弹出通知系统开发混合qml/qwidget应用程序。通知存储在列表模型中,我使用QMLQt QML窗口防止焦点窃取,qt,qml,qt5,Qt,Qml,Qt5,我正在用基于qml的弹出通知系统开发混合qml/qwidget应用程序。通知存储在列表模型中,我使用QML实例化器创建和处理弹出窗口 我的问题是,每次新通知弹出时,它都会从主窗口窃取焦点。请注意,我使用QMainWindow作为应用程序的主窗口 以下是QML代码片段: Instantiator { id: instantiator model: notificationCenter delegate: Window { id: notificationWindow col
实例化器创建和处理弹出窗口
我的问题是,每次新通知弹出时,它都会从主窗口窃取焦点。请注意,我使用QMainWindow作为应用程序的主窗口
以下是QML代码片段:
Instantiator {
id: instantiator
model: notificationCenter
delegate:
Window {
id: notificationWindow
color: "transparent"
...
变量notificationCenter
是QAbstractListModel
派生的对象,包含所有活动通知和一些设置,包括通知列表:
QList <iNotification *> m_notifications;
因此,弹出窗口本身由实例化器
在不激活的情况下将Qt.WA_show添加到窗口标志没有效果
UPD:
我已经设法解决了这个问题。窗口使用以下标志窃取焦点:
flags: Qt.FramelessWindowHint | Qt.WA_ShowWithoutActivating | Qt.WindowStaysOnTopHint
flags: Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint | Qt.Popup
但是(令人惊讶的是)没有通过以下标志窃取焦点:
flags: Qt.FramelessWindowHint | Qt.WA_ShowWithoutActivating | Qt.WindowStaysOnTopHint
flags: Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint | Qt.Popup
找到解决方案,使用
flags: Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint | Qt.Popup
而不是
flags: Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint | Qt.WA_ShowWithoutActivating
弹出代码是什么?@Mitch编辑了这个问题来澄清弹出系统