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. [SOLVED] How would you set an alpha "texture" for QBrush?
Qt 6.11 is out! See what's new in the release blog

[SOLVED] How would you set an alpha "texture" for QBrush?

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 2.7k 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.
  • B Offline
    B Offline
    BlastDV
    wrote on last edited by
    #1

    I'm developing a custom color picker for an OpenGL application and I'm using QGraphicsView to preview the changes of color the user inputs. Since I have 4 sliders (one per channel) that alter the resulting color, I realized that if I moved the alpha one to zero, the preview will turn white. I would like it to turn something else, like that common squared texture from image editors like Gimp.

    Is there any way to achieve this with QBrush?

    (8) Just live your life blind like me (8)

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

      Hi,

      Are you thinking for something like :
      @QBrush(QColor(0, 0, 255, 128))@
      ?

      It should give you a half-transparent blue brush.

      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
      • B Offline
        B Offline
        BlastDV
        wrote on last edited by
        #3

        Hi SGaist,

        No, what I would like to achieve is to show a texture on the background as the alpha channel reduces.

        Just as the background of this picture:
        http://www.cgmotionbox.com/wp-content/uploads/2011/11/Rendering-A-File-With-An-Alpha-Channel-In-After-Effects.gif

        (8) Just live your life blind like me (8)

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

          Then what about QBrush::setTexture ?

          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
          • B Offline
            B Offline
            BlastDV
            wrote on last edited by
            #5

            You're right.

            I forgot I was using a QBrush for the background, so I could use one for the foreground too. By setting a texture for the background one and tweaking the foreground colors I achieved what I was looking for.

            Thanks SGaist!

            (8) Just live your life blind like me (8)

            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