首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Flickable/TextEdit中的MouseArea不会使用propagateComposedEvents传递鼠标事件

Flickable/TextEdit中的MouseArea不会使用propagateComposedEvents传递鼠标事件
EN

Stack Overflow用户
提问于 2014-04-02 08:14:20
回答 1查看 954关注 0票数 4
代码语言:javascript
复制
import QtQuick 2.2
import QtQuick.Window 2.1
import QtQuick.Controls 1.1

ApplicationWindow {
    flags: Qt.FramelessWindowHint
    width: 500
    height: 500
    x: (Screen.width - width) / 2
    y: (Screen.height - height) / 2
    color: "black"
    opacity: 0.8

    Flickable {
        anchors.fill: parent
        contentWidth: html.paintedWidth
        contentHeight: html.paintedHeight
        boundsBehavior: Flickable.StopAtBounds
        TextEdit {
            id: html
            objectName: "html"
            anchors.fill: parent
            textFormat: TextEdit.RichText
            focus: true
            Keys.onEscapePressed: Qt.quit()
            font.family: "Droid Sans Mono"
            font.pointSize: 11
            selectByMouse: true
            readOnly: true
            MouseArea {
                anchors.fill: parent
                propagateComposedEvents: true
                onClicked: {
                    console.log("clicked")
                    mouse.accepted = false
                }
            }
        }
    }
}

我无法打印“点击”...看起来propagateComposedEventsmouse.accepted并没有像预期的那样工作。

我使用的是Qt 5.3测试版。

EN

回答 1

Stack Overflow用户

发布于 2017-02-28 17:39:43

contentWidth/Height错误,

代码语言:javascript
复制
import QtQuick 2.2
import QtQuick.Window 2.1
import QtQuick.Controls 1.1

ApplicationWindow {
    flags: Qt.FramelessWindowHint
    width: 500
    height: 500
    x: (Screen.width - width) / 2
    y: (Screen.height - height) / 2
    //color: "black"
    opacity: 0.8
    visible: true

    Flickable {
        anchors.fill: parent
        //contentWidth: html.paintedWidth
        //contentHeight: html.paintedHeight
        boundsBehavior: Flickable.StopAtBounds
        TextEdit {
            id: html
            objectName: "html"
            anchors.fill: parent
            textFormat: TextEdit.RichText
            focus: true
            Keys.onEscapePressed: Qt.quit()
            font.family: "Droid Sans Mono"
            font.pointSize: 11
            selectByMouse: true
            readOnly: true
            text: "hello world"
            MouseArea {
                anchors.fill: parent
                propagateComposedEvents: true
                onClicked: {
                    console.log("clicked")
                    mouse.accepted = false
                }
            }
        }
    }
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/22799297

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档