Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt WebKit
  4. QWebElement DOM Manipulation
Forum Update on Monday, May 27th 2025

QWebElement DOM Manipulation

Scheduled Pinned Locked Moved Qt WebKit
2 Posts 2 Posters 3.7k Views
  • 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.
  • P Offline
    P Offline
    poser
    wrote on last edited by
    #1

    I'm trying to add a default style to every rendered webpage in my browser. I've tried many different things and can't get the DOM to change. I'm using Qt 4.7.0 on Windows with VS. I believe the following should work, but the DOM doesn't get modified. Any thoughts?

    @
    void QWebView::onLoadFinished(bool error)
    {
    QWebElement style;
    style.setOuterXml("<style>*:focus{outline:1px solid red}</style>");
    style.setAttribute("type", "text/css");
    page()->mainFrame()->findFirstElement("head").appendInside(style);
    }
    @

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      Why not use QWebSettings::setUserStyleSheetUrl()? It seems that one is meant for setting a style sheet for your page. You can get a pointer to your QWebSettings instance from your QWebPage instance.

      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 Extensions
      • Unsolved