Qt World Summit: Submit your Presentation

QLabel not being updated in a QTextEdit

  • The following function is supposed to print multiple lines (cursors) with different colors and to change the height of them depending on the size of the characters

    void TextEditor::paintCursors() {
        QTextCursor cursor(document());
        for (const std::pair<int, std::pair<int, QLabel*>> &c : cursorMap) {
            int position = qMin(c.second.first, document()->characterCount()-1);
            QRect cRect = cursorRect(cursor);
            int width = cRect.width() + 1;
            int height = cRect.height();
            qDebug() << "height" << height;
            QPixmap pixmap(width, height);
            c.second.second->move(cRect.left(), cRect.top());

    The result is that the label mantains the initial height that will be not changed when altering the font size like in the following gif

    alt text

    I've tried to update() the QTextEdit and the label without any improvements

Log in to reply