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. [Somewhat Solved] Are there any "proving grounds" for stylesheets?
Qt 6.11 is out! See what's new in the release blog

[Somewhat Solved] Are there any "proving grounds" for stylesheets?

Scheduled Pinned Locked Moved General and Desktop
9 Posts 4 Posters 4.6k 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.
  • T Offline
    T Offline
    thEClaw
    wrote on last edited by
    #1

    Is there any easy way to find out if a stylesheet is styling all the standard elements Qt comes with? Like a huge window with all the different widgets, where you can load a stylesheet and see how well it works?

    If there is no such thing, would there be a way to generate such a widget without having to create it by hand?

    1 Reply Last reply
    0
    • J Offline
      J Offline
      jsprenkle
      wrote on last edited by
      #2

      They also look differently on different operating systems. The closest I know of is the widget gallery in the online documentation

      1 Reply Last reply
      0
      • T Offline
        T Offline
        thEClaw
        wrote on last edited by
        #3

        It doesn't matter if they look differently in their native state.

        Is there any sourcecode for said gallery, so one could use it to test stylesheets?

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi,

          Have a look at PATH_TO_YOUR_QT_SOURCES/examples/widgets/styles

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • T Offline
            T Offline
            thEClaw
            wrote on last edited by
            #5

            Thanks for the hint, but there are several elements missing, I think. First thing I see is that all the views are missing, and there is probably more.

            Would there be a way to automatically create an object for every non-abstract subclass of QWidget, put all of them together in some kind of layout (maybe a QFormLayout, labeling things by the className()) and then use the result for testing stylesheets? It wouldn't need to be pretty or fast, but it would be a lot more convenient than coding everything by hand.

            1 Reply Last reply
            0
            • N Offline
              N Offline
              NicuPopescu
              wrote on last edited by
              #6

              if I get it right, you need a simple test case for any kind of widgets?

              if so, just do a simple main window project and in its constructor paste this:

              @ QFile qss("style.qss");
              bool opened = qss.open(QFile::ReadOnly);
              QString data = QString::fromUtf8(qss.readAll());
              qss.close();

              setStyleSheet(data);@

              *.qss is just a convention

              do a style.qss file in your project dir and you're ready for test ... objectName will be your selector in css file

              and have always an eye on "Qt Style Sheets Reference":http://qt-project.org/doc/qt-5.0/qtwidgets/stylesheet-reference.html and doc's examples

              1 Reply Last reply
              0
              • T Offline
                T Offline
                thEClaw
                wrote on last edited by
                #7

                It's the other way around! I want to have an application/a single window that contains all the widgets that are included in Qt, each one being a proper representative of its class. And then I want to load a stylesheet, to see if everything is coherent or not. Loading the stylesheet is not the problem, however.

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  You would need to create a code generator that would go through Qt's includes and find all class derived from QWidget that are not abstract, not an easy task at all. You should rather create your gallery with the widgets you need and add others when useful.

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0
                  • T Offline
                    T Offline
                    thEClaw
                    wrote on last edited by
                    #9

                    I was hoping there was some kind of "gallery" already. Qt should definitely come with one.

                    I'll see what I do next. Thanks so far. :)

                    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