Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
qtws26_logo

The Qt Event of the Year: Qt World Summit 2026

Save Your Spot >
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QTextBrowser css trouble
Qt 6.12 LTS is out! See what's new in the release blog

QTextBrowser css trouble

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 1.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    fatinbrain
    wrote on last edited by
    #1

    Hello!
    I have problem with font-size property for <h*> tags in QTextBrowser.
    Example:
    @
    QString css = "p{color:blue;font-size:30px;}"
    "h1{color:green;font-size:50px;}"
    "h2{color:red;font-size:10px;}";
    ui->tbEye->document()->setDefaultStyleSheet(css);
    ui->tbEye->append("<h1>head1</h1><p>bass</p><h2>head2</h2>");
    @

    Result:
    !http://db.tt/86tbBDYA(QTextBrowser css result)!

    As you can see, colors and size of <p> tag are fine. But size of <h*> tags are wrong.
    I cannot understand where is my fault?

    UPDATE I grab actual _html _code from QTextBrowser.
    As I can understand, the cause of problem is that for <p> tags Qt generates font-sizes like this:

    @font-size:30px;@

    and for headers it uses predefined values like

    @font-size:xx-large;@

    Better understanding of problem, but still no solution.

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt
    • Unsolved