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

QTextBlockFormat.setForeground is useless?



  • QTextBlockFormat.setBackground is good, but QTextBlockFormat.setForeground is useless!
    https://github.com/sonichy/Qt_QQMusic

    QTextCursor cursor1(ui->textBrowser->document()->findBlockByLineNumber(hl));
    QTextBlockFormat TBF1 = cursor1.blockFormat();
    TBF1.setForeground(QBrush(Qt::green));
    TBF1.setBackground(QBrush(Qt::yellow));
    cursor1.setBlockFormat(TBF1);
    ui->textBrowser->setTextCursor(cursor1);

Log in to reply