qt - QLabel text alignment with rich text and <tt> -


i have qlabel that's displaying rich text (i. e. subset of html supported qt) , uses <tt> tag (for monospaced font). seems mess vertical alignment of whole label text (not monospaced part).

as example, here 9 qlabels in grid layout. text of center label "text<tt>label</tt>", while text of other labels "textlabel". text of center label aligned 3 pixels lower others.

screenshot

needless say, messes layout , causes annoying layout changes when text changed value doesn't contain monospaced font.

how can text align other labels?

qt 5.5.1 on ubuntu 16.04 gnome 3.18.2.

tl;dr: using <span style="font-family: monospace">...</span> instead of <tt>...</tt> fixed issue me.

looking @ following screenshot, impression issue related courier new font:

  • the blue label (top) has font set courier new. has additional space above text.
  • the red label (center) uses <tt> in question. qt chooses courier new font , has additional space above text.
  • the green label (bottom) uses font-family: monospace described above (for "label" part of text); qt chooses different monospaced font (not sure one) , spacing fine.

enter image description here


Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -