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. QCss::Parser -- how to reproduce behavior?
QtWS25 Last Chance

QCss::Parser -- how to reproduce behavior?

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 546 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.
  • E Offline
    E Offline
    Ewan Green
    wrote on last edited by
    #1

    The QCss::Parser class could be incredibly useful for the average Qt user if they want to test the sanity of stylesheets themselves.
    This could be in a situation where the program's stylesheets are user-definable, and they want to spare the application of having an erroneous style applied to it, even though the program will still run. I know that the invalid selectors will not be applied to, but I want this to be recognizable on the basis in which I'm setting the stylesheet.

    Judging by the fact that the actual code for this is not provided, and only acknowledgable through the includes, I've assumed behavior is different depending on the platform/version of Qt. Why is this?

    More importantly, how can I reproduce this behavior without adding gui-private and jeopardizing my stability and ability to run on differing modules (not to mention the errors)? Is there an underlying class/framework that this parser uses? I'm talking specifically about the QCss::Parser::parse() method.

    Ewan Green

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by mrjj
      #2

      Hi
      The parser seems handwritten.

      https://code.woboq.org/qt5/qtbase/src/gui/text/qcssparser_p.h.html

      https://code.woboq.org/qt5/qtbase/src/gui/text/qcssparser.cpp.html

      1 Reply Last reply
      0
      • E Offline
        E Offline
        Ewan Green
        wrote on last edited by Ewan Green
        #3

        I did end up looking at the source file between now and when I posted initially.
        I see how they did the parsing, and it isn't very flexible for re-implementation. Seeing as how it already exists in the source, and is undeniably being used somewhere down the line when stylesheets are used, I just think it's so ridiculous they don't allow public access to this method or something similar. Even if it were the easiest thing to re-implement, doing so is not my favorite idea if the code is already "available" to me (so to speak).

        Do you know of anyone who has faced this issue & the solution they came up with?

        Ewan Green

        mrjjM 1 Reply Last reply
        0
        • E Ewan Green

          I did end up looking at the source file between now and when I posted initially.
          I see how they did the parsing, and it isn't very flexible for re-implementation. Seeing as how it already exists in the source, and is undeniably being used somewhere down the line when stylesheets are used, I just think it's so ridiculous they don't allow public access to this method or something similar. Even if it were the easiest thing to re-implement, doing so is not my favorite idea if the code is already "available" to me (so to speak).

          Do you know of anyone who has faced this issue & the solution they came up with?

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @Ewan-Green
          Hi
          well the use of _p private headers is to keep as much as possible as
          implementation details as Qt promise backward compatibility so
          they are careful what makes it to public interfaces.

          If they allowed access to parse it would have to return its internal data structures
          and hence it would have become public.
          However, I agree. They could at least return parse status with err number and line
          if it had errors.

          It has been asked on forums a few times and solutions range from copy the parser files and make own version to using external lib like http://www.netsurf-browser.org/projects/libcss/

          1 Reply Last reply
          2
          • E Offline
            E Offline
            Ewan Green
            wrote on last edited by
            #5

            Thank you.

            Ewan Green

            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