May 2019
Intermediate to advanced
542 pages
13h 37m
English
Qt rich text documents do not support HTML <style> tags or <link> tags for setting a document-wide style sheet. Instead, you can use the setDefaultStyleSheet() method of the QTextDocument object to set a CSS style sheet that will be applied to all viewed documents.
Back in MainWindow.__init__(), add the following:
main.document().setDefaultStyleSheet( 'body {color: #333; font-size: 14px;} ' 'h2 {background: #CCF; color: #443;} ' 'h1 {background: #001133; color: white;} ' )
Note, however, that this must be added before the HTML is inserted into the widget. The defaultStyleSheet method is only applied to newly inserted HTML.
Also note that certain aspects of the appearance are not properties of the document, but of the ...
Read now
Unlock full access