qtextbrowser

Why Unicode fonts are not showing properly in the QTextBrowser when Unicode contents are read from an html file?

a 夏天 提交于 2019-12-02 03:22:04
I am reading an html file. The file basically contains Unicode texts as follows: <b>akko- sati (ā + kruś), akkhāti (ā + khyā), abbahati (ā + bṛh)</b> But the QTextBrowser is not interpreting the Unicode fonts. So the QTextBrowser shows them as follows: akko- sati (Ä + kruÅ›), akkhÄti (Ä + khyÄ), abbahati (Ä + bá¹›h) The QTextBrowser is correctly interpreting the html tags. But what’s wrong with the Unicode fonts? Following are my codes for reading and populating the Unicode contents: void MainWindow::populateTextBrowser(const QModelIndex &index) { QFile file("Data\\" + index.data().toString()

PySide/PyQt: Is it possible to make strings that you attach to the QTextBrowser separate clickable units

元气小坏坏 提交于 2019-12-02 00:19:05
This might be a silly question but: When you append a given string to a QTextBrowser object, can you make it a link to a signal to a function that takes its text and does something with it? All I need is for it to save the text to a variable actually. As in, can a link lead to a function instead of to a website. It certainly is possible. Here is a code example: import sys from PyQt4 import QtGui from PyQt4 import QtCore class MainWindow(QtGui.QWidget): def __init__(self): super(MainWindow, self).__init__() main_layout = QtGui.QVBoxLayout() self.browser = QtGui.QTextBrowser() self.browser