【问题标题】:newline symbol in qml Textfield, text property not workingqml Textfield中的换行符,文本属性不起作用
【发布时间】:2017-10-09 07:32:28
【问题描述】:

是否可以在 TextField 组件的 text 属性中插入换行符:

import QtQuick 2.6
import QtQuick.Controls 1.2
import QtQuick.Window 2.2

Window {
    visible: true
    width: 640
    height: 480

    Grid {
        TextField {
            text: "Text\nhere"
        }
    }
}

在文本字段中打印空白而不是换行符

【问题讨论】:

    标签: qt qml qt5


    【解决方案1】:

    根据docs

    TextField 用于接受一行文本输入。 [...]

    因此,该项目中不能有多行。您必须使用另一个项目,例如 TextArea

    import QtQuick 2.6
    import QtQuick.Controls 1.2
    import QtQuick.Window 2.2
    
    Window {
        visible: true
        width: 640
        height: 480
    
        Grid {
            TextArea {
                text: "Text\nshere"
            }
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-06-10
      • 1970-01-01
      • 1970-01-01
      • 2011-06-19
      • 2014-03-24
      • 1970-01-01
      • 1970-01-01
      • 2012-01-06
      相关资源
      最近更新 更多