Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Emulate a javascript function in a qss stylesheet
Forum Updated to NodeBB v4.3 + New Features

Emulate a javascript function in a qss stylesheet

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 3 Posters 358 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.
  • P Offline
    P Offline
    PeteVick
    wrote on last edited by
    #1

    I've been creating some stylesheets for an open source cad software called Qcad which is QT based. The stylesheets allow the user different themes for Qcad. One element of Qcad is a history window - QTextBrowser#History that displays three different colors using rich text. This is done by a javascript file that I am not able edit. I do know that the javascript I'm interested in is the first line of the following snippet....

    EcmaScriptShell.col = "#000";
    EcmaScriptShell.colWarning = "#cc0000";
    EcmaScriptShell.colPrompt = "#0000cc";
    

    this turns the font color black in certain parts of the history window, I want that font to be white. So what I'm asking is, is there any way at all to emulate the above snippet in a sylesheet. I've tried the obvious....

    QTextBrowser#History {
        color: #fff;
    }
    

    ..and it has no effect at all, I've tried variations on the above but nothing works. I did think about running a javascript file from the stylesheet, but soon found out that wasn't possible.
    I'm beginning to think that it's just not possible in a stylesheet.

    JonBJ 1 Reply Last reply
    0
    • P PeteVick

      I've been creating some stylesheets for an open source cad software called Qcad which is QT based. The stylesheets allow the user different themes for Qcad. One element of Qcad is a history window - QTextBrowser#History that displays three different colors using rich text. This is done by a javascript file that I am not able edit. I do know that the javascript I'm interested in is the first line of the following snippet....

      EcmaScriptShell.col = "#000";
      EcmaScriptShell.colWarning = "#cc0000";
      EcmaScriptShell.colPrompt = "#0000cc";
      

      this turns the font color black in certain parts of the history window, I want that font to be white. So what I'm asking is, is there any way at all to emulate the above snippet in a sylesheet. I've tried the obvious....

      QTextBrowser#History {
          color: #fff;
      }
      

      ..and it has no effect at all, I've tried variations on the above but nothing works. I did think about running a javascript file from the stylesheet, but soon found out that wasn't possible.
      I'm beginning to think that it's just not possible in a stylesheet.

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

      @PeteVick
      Cannot be done from stylesheet. CSS/QSS and JS have no relationship. And even if you could their JS script would like overwrite your efforts anyway. But if their thing is JS, it shouldn't be being executed in a QWebBrowser anyway....

      You have to go to QWebEnginePage if you want to play with JS.

      P 1 Reply Last reply
      1
      • JonBJ JonB

        @PeteVick
        Cannot be done from stylesheet. CSS/QSS and JS have no relationship. And even if you could their JS script would like overwrite your efforts anyway. But if their thing is JS, it shouldn't be being executed in a QWebBrowser anyway....

        You have to go to QWebEnginePage if you want to play with JS.

        P Offline
        P Offline
        PeteVick
        wrote on last edited by
        #3

        @JonB thanks for the reply, you've confirmed my thoughts. Not sure that I have any options left to me now

        1 Reply Last reply
        0
        • K Offline
          K Offline
          Krakenus00
          wrote on last edited by Krakenus00
          #4

          If I get it right, you can try CSS-like states (or pseudo-classes).
          For example, consider a button with the next style:

          QToolButton#MyBtn {
          	background-color: #000;
          }
          QToolButton#MyBtn:hovered {
          	background-color: #FFF;
          }
          

          It is black by default and white when hovered.

          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