首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >MouseArea禁止编辑

MouseArea禁止编辑
EN

Stack Overflow用户
提问于 2016-09-06 02:10:09
回答 1查看 59关注 0票数 1

我有以下代码:

代码语言:javascript
复制
import QtQuick 2.4
import QtQuick.Controls 1.4

ApplicationWindow
{
    id: myWindow2
    title: qsTr("test window")
    x: 500
    y: 200
    width: 800
    height: 600
    visible: true

    TextEdit
    {
        id: tEdit

        anchors.fill: parent

        MouseArea
        {
            anchors.fill: parent
            cursorShape: Qt.IBeamCursor
        }
    }
}

不知何故,“MouseArea”阻止了“tEdit”的工作。它确实改变了光标的形状。我怎样才能改变形状和'tEdit‘呢?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-09-06 02:39:35

acceptedButtons设置为Qt.NoButton似乎是可行的:

代码语言:javascript
复制
import QtQuick 2.4
import QtQuick.Controls 1.4

ApplicationWindow {
    id: myWindow2
    x: 500
    y: 200
    width: 800
    height: 600
    visible: true

    TextEdit {
        id: tEdit
        anchors.fill: parent

        MouseArea {
            anchors.fill: parent
            cursorShape: Qt.IBeamCursor
            acceptedButtons: Qt.NoButton
        }
    }
}

请注意,通过鼠标选择文本仍然有效,您只需将其设置为true:

代码语言:javascript
复制
selectByMouse: true
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/39335785

复制
相关文章

相似问题

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