Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How to avoid text over flow in TextEdit



  • I have text edit inside the filckable and text area has lot of data. Flickable is bounded by rectangle.
    when i flick i want the text to be with the bounded rectangle. Now it is over flowing rectangle.
    How to avoid text over flow in TextEdit, if we have long text in it?

    import QtQuick 2.14
    import QtQuick.Window 2.14
    
    Window {
        id : t1
        visible: true
        width: 640
        height: 480
        title: qsTr("Hello World")
        
        property string data1 :"
    19:49:18: Running steps for project TextEditScroll...
    19:49:18: Configuration unchanged, skipping qmake step.
    19:49:18: Starting: /usr/bin/make -j4
    19:49:19: Elapsed time: 00:00-1.
    19:49:18: Running steps for project TextEditScroll...
    19:49:18: Configuration unchanged, skipping qmake step.
    19:49:18: Starting: /usr/bin/make -j4
    19:49:19: Elapsed time: 00:00.
    19:49:18: Running steps for project TextEditScroll...
    19:49:18: Configuration unchanged, skipping qmake step.
    19:49:18: Starting: /usr/bin/make -j4
    19:49:19: Elapsed time: 00:00-2.
    19:49:18: Running steps for project TextEditScroll...
    19:49:18: Configuration unchanged, skipping qmake step.
    19:49:18: Starting: /usr/bin/make -j4
    19:49:19: Elapsed time: 00:00-3.
    19:49:18: Running steps for project TextEditScroll...
    19:49:18: Configuration unchanged, skipping qmake step.
    19:49:18: Starting: /usr/bin/make -j4
    19:49:19: Elapsed time: 00:00-4.
    19:49:18: Running steps for project TextEditScroll...
    19:49:18: Configuration unchanged, skipping qmake step.
    19:49:18: Starting: /usr/bin/make -j4
    19:49:19: Elapsed time: 00:00-5.
    19:49:18: Running steps for project TextEditScroll...
    19:49:18: Configuration unchanged, skipping qmake step.
    19:49:18: Starting: /usr/bin/make -j4
    19:49:19: Elapsed time: 00:00-6.
    19:49:18: Running steps for project TextEditScroll...
    19:49:18: Configuration unchanged, skipping qmake step.
    19:49:18: Starting: /usr/bin/make -j4
    19:49:19: Elapsed time: 00:00-7.
    19:49:18: Running steps for project TextEditScroll...
    19:49:18: Configuration unchanged, skipping qmake step.
    19:49:18: Starting: /usr/bin/make -j4
    19:49:19: Elapsed time: 00:00-8."
        Rectangle{
            width: 500
            height: 400
            border.color: "blue"
            border.width: 2
            color: "lightgray"
            anchors.centerIn: parent
            z:5
            Flickable{
                id : flickable
                width: 500;
                height: 400
                contentWidth: t3.width; contentHeight: t3.height
                flickableDirection:Flickable.VerticalFlick
                z:3
                TextEdit{
                    id:t3
                    text: t1.data1
                    clip: true
                    z:1
                }
            }
        }
    }
    

    scroll2.png



  • @Rajashekara-V hi
    you can set clip: true on the parent rectangle

    see also https://wiki.qt.io/Flickable_Wrapped_TextEdit



  • @Rajashekara-V hi
    you can set clip: true on the parent rectangle

    see also https://wiki.qt.io/Flickable_Wrapped_TextEdit


Log in to reply