2014-04-02 63 views
3
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預期只是不工作。鼠標區域Flickable /文本編輯內不使用propagateComposedEvents

我正在使用Qt 5.3 Beta。

回答

0

contentWidth /身高是錯誤的,

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 
       } 
      } 
     } 
    } 
} 
相關問題