【问题标题】:Qt5.8 QML Why does a read-only Controls2.TextArea have the ibeam cursor?Qt5.8 QML 为什么只读的 Controls2.TextArea 有 ibeam 光标?
【发布时间】:2017-02-01 21:23:40
【问题描述】:

Qt5.7 这个例子给出了“指针”光标,但是 Qt5.8,我得到了“ibeam”光标(就像我要插入一样)。

import QtQuick 2.7
import QtQuick.Controls 2

ApplicationWindow
{
    width: 1024
    height: 800

    visible: true

    Flickable 
    {
        anchors.fill: parent
        flickableDirection: Flickable.VerticalFlick

        TextArea.flickable: TextArea
        {
            font.pixelSize: 25
            text: "hello world"
            readOnly: true
        }
    }
}

这是有意更改吗,如果是,我如何显示只读 TextArea 的指针光标?

谢谢。

更新 #1:

添加一个虚拟MouseArea 似乎可以修复它。我不知道为什么/

像这样:

 Flickable 
    {
        anchors.fill: parent
        flickableDirection: Flickable.VerticalFlick

        TextArea.flickable: TextArea
        {
            font.pixelSize: 25
            text: "hello world"
            readOnly: true

            MouseArea 
            {
                anchors.fill: parent
                enabled: false
            }
        }
    }

【问题讨论】:

  • 听起来像是一个应该很容易修复的疏忽。请在 bugreports.qt.io 报告。
  • @jpnurmi 谢谢。我找到了一种解决方法,但我不明白它为什么有效。无论如何...
  • 可能是因为MouseArea 的默认cursorShapeQt.ArrowCursordoc.qt.io/qt-5/qml-qtquick-mousearea.html#cursorShape-prop。顺便说一句,你能回答你的问题并接受它,这样我们就知道它已经解决了吗? :)
  • 该错误已在 Qt 5.8.1 和/或 5.9.0 中修复:codereview.qt-project.org/#/c/185002
  • 感谢您的错误修复!我同时发布了这个效果的答案和我的解决方法。

标签: qt qml qtquickcontrols2 qt5.8


【解决方案1】:

在 Mitch 和 Jpnurmi 的 cmets 之后,显然这是一个现已修复的错误。太好了!

与此同时,我的解决方法是一个虚拟的MouseArea

 TextArea.flickable: TextArea
        {
            font.pixelSize: 25
            text: "hello world"
            readOnly: true

            MouseArea 
            {
                anchors.fill: parent
                enabled: false
            }
        }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-11-29
    • 1970-01-01
    • 1970-01-01
    • 2011-02-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多