Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QLabel not being updated in a QTextEdit
Forum Updated to NodeBB v4.3 + New Features

QLabel not being updated in a QTextEdit

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 134 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    anphetamina
    wrote on last edited by
    #1

    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);
            cursor.setPosition(position);
            QRect cRect = cursorRect(cursor);
            int width = cRect.width() + 1;
            int height = cRect.height();
            qDebug() << "height" << height;
            QPixmap pixmap(width, height);
            pixmap.fill(getUserColor(c.first));
            c.second.second->move(cRect.left(), cRect.top());
            c.second.second->setPixmap(pixmap);
            c.second.second->show();
        }
    }
    

    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

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved