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. ColorOverlay in GridLayout
Forum Updated to NodeBB v4.3 + New Features

ColorOverlay in GridLayout

Scheduled Pinned Locked Moved Solved QML and Qt Quick
7 Posts 3 Posters 2.7k Views 2 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.
  • beeckscheB Offline
    beeckscheB Offline
    beecksche
    wrote on last edited by
    #1

    Hi,
    i want to show some images in a grid layout. To override the color of the images i use the ColorOverlay class.

    Item {
        id: item1
        GridLayout {
            anchors.fill: parent
            columns: 2
    
            Image {
                id: im1
                source: "qrc:/images/im1.png"
                sourceSize.width: 75
                sourceSize.height: 75
                smooth: true
                visible: false
            }
    
            ColorOverlay {
                anchors.fill: im1
                source: im1
                color: "red"
            }
    
            Image {
                id: im2
                source: "qrc:/images/im2.png"
                sourceSize.width: 75
                sourceSize.height: 75
                smooth: true
                visible: false
            }
    
            ColorOverlay {
                anchors.fill: im2
                source: im2
                color: "red"
            }
    }
    
    

    The color of the images is changed but unfortunately they all appear in the upper left corner of the window.

    Do i need to change some properties?

    Thanks!

    raven-worxR Julien BJ 2 Replies Last reply
    0
    • beeckscheB beecksche

      Hi,
      i want to show some images in a grid layout. To override the color of the images i use the ColorOverlay class.

      Item {
          id: item1
          GridLayout {
              anchors.fill: parent
              columns: 2
      
              Image {
                  id: im1
                  source: "qrc:/images/im1.png"
                  sourceSize.width: 75
                  sourceSize.height: 75
                  smooth: true
                  visible: false
              }
      
              ColorOverlay {
                  anchors.fill: im1
                  source: im1
                  color: "red"
              }
      
              Image {
                  id: im2
                  source: "qrc:/images/im2.png"
                  sourceSize.width: 75
                  sourceSize.height: 75
                  smooth: true
                  visible: false
              }
      
              ColorOverlay {
                  anchors.fill: im2
                  source: im2
                  color: "red"
              }
      }
      
      

      The color of the images is changed but unfortunately they all appear in the upper left corner of the window.

      Do i need to change some properties?

      Thanks!

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by raven-worx
      #2

      @beecksche
      try it this way (overlay is a child of the image):

      Image {
                  id: im1
                  source: "qrc:/images/im1.png"
                  sourceSize.width: 75
                  sourceSize.height: 75
                  smooth: true
                  visible: false
      
                  ColorOverlay {
                       anchors.fill: parent
                       source: parent
                       color: "red"
                  }
              }
      

      or wrap the image and the overlay inside a new Item element (like in the example)

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      beeckscheB 1 Reply Last reply
      3
      • raven-worxR raven-worx

        @beecksche
        try it this way (overlay is a child of the image):

        Image {
                    id: im1
                    source: "qrc:/images/im1.png"
                    sourceSize.width: 75
                    sourceSize.height: 75
                    smooth: true
                    visible: false
        
                    ColorOverlay {
                         anchors.fill: parent
                         source: parent
                         color: "red"
                    }
                }
        

        or wrap the image and the overlay inside a new Item element (like in the example)

        beeckscheB Offline
        beeckscheB Offline
        beecksche
        wrote on last edited by beecksche
        #3

        @raven-worx said in ColorOverlay in GridLayout:

        @beecksche
        try it this way (overlay is a child of the image):

        Image {
                    id: im1
                    source: "qrc:/images/im1.png"
                    sourceSize.width: 75
                    sourceSize.height: 75
                    smooth: true
                    visible: false // visible: true !
        
                    ColorOverlay {
                         anchors.fill: parent
                         source: parent
                         color: "red"
                    }
                }
        

        I need to change visible: true, so it works perfectly for me! Thanks!

        1 Reply Last reply
        0
        • beeckscheB Offline
          beeckscheB Offline
          beecksche
          wrote on last edited by
          #4

          @raven-worx
          Now i recognized the following error:

          ShaderEffectSource: 'recursive' must be set to true when rendering recursively.

          raven-worxR 1 Reply Last reply
          0
          • beeckscheB beecksche

            @raven-worx
            Now i recognized the following error:

            ShaderEffectSource: 'recursive' must be set to true when rendering recursively.

            raven-worxR Offline
            raven-worxR Offline
            raven-worx
            Moderators
            wrote on last edited by
            #5

            @beecksche
            then my suggestion (to put ColorOverlay inside the Image) was wrong i guess

            --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
            If you have a question please use the forum so others can benefit from the solution in the future

            1 Reply Last reply
            0
            • beeckscheB beecksche

              Hi,
              i want to show some images in a grid layout. To override the color of the images i use the ColorOverlay class.

              Item {
                  id: item1
                  GridLayout {
                      anchors.fill: parent
                      columns: 2
              
                      Image {
                          id: im1
                          source: "qrc:/images/im1.png"
                          sourceSize.width: 75
                          sourceSize.height: 75
                          smooth: true
                          visible: false
                      }
              
                      ColorOverlay {
                          anchors.fill: im1
                          source: im1
                          color: "red"
                      }
              
                      Image {
                          id: im2
                          source: "qrc:/images/im2.png"
                          sourceSize.width: 75
                          sourceSize.height: 75
                          smooth: true
                          visible: false
                      }
              
                      ColorOverlay {
                          anchors.fill: im2
                          source: im2
                          color: "red"
                      }
              }
              
              

              The color of the images is changed but unfortunately they all appear in the upper left corner of the window.

              Do i need to change some properties?

              Thanks!

              Julien BJ Offline
              Julien BJ Offline
              Julien B
              wrote on last edited by Julien B
              #6

              Hello @beecksche ,

              What happens if you but both Image and ColorOverlay in an Ìtem as @raven-worx suggested?

              beeckscheB 1 Reply Last reply
              1
              • Julien BJ Julien B

                Hello @beecksche ,

                What happens if you but both Image and ColorOverlay in an Ìtem as @raven-worx suggested?

                beeckscheB Offline
                beeckscheB Offline
                beecksche
                wrote on last edited by beecksche
                #7

                @raven-worx , @Julien-B

                Worked!

                Thanks!!

                        Item {
                            width: image.width
                            height: image.height
                
                            Image {
                                id: image
                                fillMode: Image.PreserveAspectFit
                                source: "qrc:/images/image.png"
                                sourceSize.width: 50
                                sourceSize.height: 50
                                smooth: true
                                visible: false
                            }
                
                            ColorOverlay {
                                 color: "red"
                                 anchors.fill: image
                                 source: image
                            }
                        }
                
                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