'Pyqt5 Change styles of spesific lines in QTextBrowser

I'm making a dictionary style program with pyqt5.

When you select the words, the explanation appears in QTextBrowser.

What I want is for the text on the first line of the QTextBrowser to be different from the style of the other lines.

I tried a few solutions on my own, but I couldn't, my code puts all lines in the QTextBrowser in the same style.

    def settextfont(self):
        font = self.font()
        font.setFamily(u"MS Shell Dlg 2")
        font.setItalic(True)
        font.setPixelSize(14)
        self.ui.textBrowser_2.setTextColor(QColor('#434343'))
        self.ui.textBrowser_2.setFont(font)

The result my code does:

enter image description here

What I want should be:

enter image description here

I hope I was able to explain.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source