2 Different fonts in a QTextEdit
Solved
General and Desktop
-
@JonB
Here it is the code:void MainWindow::on_fontComboBox_currentFontChanged(const QFont &f) { ui->fontComboBox->setFont(f); QTextEdit *edit = getTabTextEdit(); if(ui->tabWidget->currentWidget() == ui->tab_1) { ui->edit->setFont(f); } else { edit->setFont(f); } }
-
@HenkCoder
You are indeed setting the font for the wholeQTextEdit
.Have you taken the time to read through https://doc.qt.io/qt-5/qtextedit.html#details? You can either use a text cursor and
setCurrentCharFormat()
etc., or append HTML text with the desired font in it. Googleqtextedit multiple fonts
, e.g. Using different fonts/attributes in QTextEdit.