Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Any way to smooth Gradients?
Forum Updated to NodeBB v4.3 + New Features

Any way to smooth Gradients?

Scheduled Pinned Locked Moved QML and Qt Quick
10 Posts 4 Posters 6.9k 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.
  • K Offline
    K Offline
    kyleplattner
    wrote on last edited by
    #1

    All the gradients look great when I run them on my desktop QML Viewer but as soon as I look at them on my linux touch screen display they look very choppy (squares). I know the smooth:true attribute helped clean the edges of shapes, but how can I clean gradients. ?

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mbrasser
      wrote on last edited by
      #2

      Are these gradients in pixmaps, or the gradient support of Rectangle? Rectangle uses standard Qt gradient drawing for this, so there shouldn't be anything special you need to set (that I'm aware). If in a pixmap, the issue might be related to the bit-depth of the screen (e.g. if your image was 32bit and you were displaying it on a 16bit screen)?

      1 Reply Last reply
      0
      • K Offline
        K Offline
        kyleplattner
        wrote on last edited by
        #3

        It is just the normal QML rectangle gradient. I wonder though if the 16bit / 8bit display isn't making the difference. Any way to know?

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

          Does a picture with the same gradient show properly in that QML application?
          Note that using pictures with gradients is the recommended way of working for most cases anyway. It is faster than generating and drawing real gradients all the time.

          1 Reply Last reply
          0
          • X Offline
            X Offline
            xsacha
            wrote on last edited by
            #5

            I have created gradient backgrounds by making a thin image (like 1x640 or 1x400) with my gradient line and then tiling/stretching it horizontally. Smooth attribute will work on this to smooth it too.

            • Sacha
            1 Reply Last reply
            0
            • K Offline
              K Offline
              kyleplattner
              wrote on last edited by
              #6

              I thought QML would always be quicker than loading a png file. Good to know.

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

                Blitting something loaded into memory to the screen is always going to be faster than rendering from scratch, as I understand it.

                Disclaimer: I am far from a graphics expert.

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  mbrasser
                  wrote on last edited by
                  #8

                  [quote author="kyleplattner" date="1293027447"]I thought QML would always be quicker than loading a png file. Good to know. [/quote]

                  In general, QML will always try to draw things the fastest way. Often this means that we internally cache things to a pixmap (for example, for 4.7.0 all Text is internally cached to a pixmap, though in 4.7.2 we will switch to using a QStaticText-like solution, which retains good performance and uses less memory). In terms of drawing a vertical linear gradient in a plain rectangle, that can be optimized quite well without caching, so we don't cache to a pixmap. (A gradient in a rounded rect, or bordered rect, however, is not well optimized)

                  There are certainly cases when using your own pre-composed image is the best way to go, see for example http://doc.qt.nokia.com/4.7-snapshot/qdeclarativeperformance.html#image-resources-over-composition.

                  Regards,
                  Michael

                  1 Reply Last reply
                  0
                  • M Offline
                    M Offline
                    mbrasser
                    wrote on last edited by
                    #9

                    [quote author="kyleplattner" date="1292939771"]It is just the normal QML rectangle gradient. I wonder though if the 16bit / 8bit display isn't making the difference. Any way to know?[/quote]

                    It's certainly worth trying an image, and comparing the results.

                    Regards,
                    Michael

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

                      [quote author="mbrasser" date="1293060738"]In general, QML will always try to draw things the fastest way. Often this means that we internally cache things to a pixmap (for example, for 4.7.0 all Text is internally cached to a pixmap, though in 4.7.2 we will switch to using a QStaticText-like solution, which retains good performance and uses less memory). In terms of drawing a vertical linear gradient in a plain rectangle, that can be optimized quite well without caching, so we don't cache to a pixmap. (A gradient in a rounded rect, or bordered rect, however, is not well optimized)

                      There are certainly cases when using your own pre-composed image is the best way to go, see for example http://doc.qt.nokia.com/4.7-snapshot/qdeclarativeperformance.html#image-resources-over-composition.
                      [/quote]

                      Thanks for the explanation! Interesting that it seems to contradict the advice given at the Dev Days on this, but perhaps I just misunderstood. Still, I am very glad that there is constant work being done to improve performance. I guess in the end, there is no substitute for just measuring what performs better for your own specific case.

                      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