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

Blinking cursor leaving an artifact in QTextEdit



  • Our Qt product has recently tried to upgrade from Qt 5.10 to 5.15. We worked through most of our issues with only a few outstanding. One of them is proving very difficult and stubborn!

    We have a blinking cursor in a QTextEdit that's leaving an artifact while blinking after an image is inserted into the QTextEdit. You can clearly see this in the animated GIF below.
    artifact.gif

    We're using a QTextImageFormat when inserting the image.

        QTextImageFormat format;
        format.setName(svgFileLocation);
    
        QSvgRenderer renderer(svgFileLocation);
        const auto height = 19;
        QImage image(height, height, QImage::Format_ARGB32);
        image.fill(Qt::transparent);
        QPainter painter(&image);
        renderer.render(&painter);
    
        // This line causes the cursor blinking issues!
        // Comment out this line and the blinking cursor is fixed (but the format is not correct)
        format.setVerticalAlignment(QTextCharFormat::AlignBottom);
    

    The line of code that causing problems is:

        format.setVerticalAlignment(QTextCharFormat::AlignBottom);
    

    The above line didn't work in Qt 5.10 ... we needed to use the line below instead (and this doesn't work in Qt 5.15!)

        format.setVerticalAlignment(QTextCharFormat::AlignBaseline);
    

    Here's a link to a Visual Studio solution and qrc file that reproduces the problem. It's a tiny little app with a total of 50 lines of code.
    https://drive.google.com/file/d/1CGf1vErbcsDHnzyiHIq4-DzytGR7RdT9/view

    Is this a known bug or has something else changes around QTextImageFormat that we're not aware of?


  • Lifetime Qt Champion

    Hi,

    Looks like it could be a regression. To see if it's known, the best thing to do is to check the bug report system.

    You might want to first test with the latest release of Qt 5.15 to see if it has been fixed in between,



  • Thanks @SGaist
    I created a bug here: https://bugreports.qt.io/browse/QTBUG-86823
    It's been triaged and is a P2


Log in to reply