Learn what Felgo offers to help your business succeed. Start your free evaluation today! Felgo for Your Business

Forums

OverviewFelgo 2 Support (Qt 5) › Adding visible cursor to AppTextEdit

Tagged: 

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #22082

    Gabor

    Hi,

    I am using the following sample code:

    App {
        Page {
    
            // remove focus from textedit if background is clicked
            MouseArea {
                anchors.fill: parent
                onClicked: textEdit.focus = false
            }
    
            // background for input
            Rectangle {
                anchors.fill: textEdit
                anchors.margins: -dp(8)
                color: "lightgrey"
            }
    
            // input
            AppTextEdit {
                id: textEdit
                width: dp(200)
                placeholderText: "What's your name?"
                anchors.centerIn: parent
            }
        }
    }

    How can I add a visible cursor to this field? At this point I can type into the field and the placeholder disappears, but the cursor is never visible.

    Thank you for your help.

    #22110

    Alex
    Felgo Team

    Hi,

    did you try changing the cursorColor property of the AppTextEdit? Maybe it has the same color as your current background.

    Best,
    Chris

    #22113

    Gabor

    Hi Alex,

    I tried. What happens is if I run the app from the Felgo Live Server there is no cursor. If I run it from Qt Creator there is a cursor. I think it should not matter which way I run it because there is no background C++ in this program. Any idea what causes the problem?

    Thank you.

    #22122

    Alex
    Felgo Team

    Hi Gabor,

    what platform are you testing on?

    Cheers,
    Alex

    #22126

    Gabor

    Hi Alex,

    I am using Windows 10.

    I came up with the following code:

    Rectangle {
            id: descrPlaceholder
            //            property int margins: 20
            //            x: margins
            //            y: margins
            anchors.margins: -dp(8)
            width: imageViewer.width
            anchors.top: imageViewer.bottom
            anchors.topMargin: dp(10)
            anchors.left: imageViewer.left
            anchors.leftMargin: dp(2)
            anchors.horizontalCenter: imageViewer.horizontalCenter
            height: dp(150)
            border.color: ST.borderClr()
            border.width: dp(2)
            radius: dp(10)
            color: ST.editBackground()
    
            Flickable {
                id: flick
    
                width: descrPlaceholder.width
                height: descrPlaceholder.height
                contentWidth: descrption.paintedWidth
                contentHeight: descrption.paintedHeight
                clip: true
    
                function ensureVisible(r) {
                    if (contentX >= r.x)
                        contentX = r.x
                    else if (contentX + width <= r.x + r.width)
                        contentX = r.x + r.width - width
                    if (contentY >= r.y)
                        contentY = r.y
                    else if (contentY + height <= r.y + r.height)
                        contentY = r.y + r.height - height
                }
    
                AppTextEdit {
                    id: descrption
                    width: flick.width
                    height: flick.height
                    placeholderText: qsTr("\n Describe the Friend:")
                    placeholderColor: ST.placeHColor()
                    cursorColor: ST.cursorClr()
                    color: ST.textColor()
                    cursorPosition: 12
                    flickable: cursorInView = true
                    focus: true
                    wrapMode: TextEdit.WordWrap
                    verticalAlignment: TextEdit.AlignLeft
                    textMargin: dp(5)
                    selectionColor: "lightgray"
                    onCursorRectangleChanged: flick.ensureVisible(cursorRectangle)
                }
            }
        }

    Again, it works without error if I run it from Qt Editor, but no cursor if I run it from Felgo Live Server.

    #22140

    Alex
    Felgo Team

    Hi,

    could you post a minimal code example that can be run without further dependencies to reproduce the issue?

    Best,
    Alex

    #22143

    Gabor

    I updated Qt to the latest version and now I have cursor in both cases.

Viewing 7 posts - 1 through 7 (of 7 total)

RSS feed for this thread

You must be logged in to reply to this topic.

Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded