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. Make background of Quick Controls 2 StackView transparent
QtWS25 Last Chance

Make background of Quick Controls 2 StackView transparent

Scheduled Pinned Locked Moved Solved QML and Qt Quick
qmlstackviewquick controlscontrols 2
8 Posts 4 Posters 2.6k 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.
  • I Offline
    I Offline
    ivarec
    wrote on last edited by ivarec
    #1

    I've designed an application that has a background image and a StackView in front of it. Some of those views are simply a few buttons with no background, so I would like to see my app's background in these cases. However, all I see now is a white background that comes from the StackView itself.

    Is there a way to make this white background transparent? I've tried setting its color property to Qt.transparent, but then my views disappear as well.

    T 1 Reply Last reply
    1
    • I ivarec

      I've designed an application that has a background image and a StackView in front of it. Some of those views are simply a few buttons with no background, so I would like to see my app's background in these cases. However, all I see now is a white background that comes from the StackView itself.

      Is there a way to make this white background transparent? I've tried setting its color property to Qt.transparent, but then my views disappear as well.

      T Offline
      T Offline
      Tom_H
      wrote on last edited by
      #2

      @ivarec What color property? StackView doesn't have one. Try setting the StackView background to the ApplicationWindow background.

      I 1 Reply Last reply
      0
      • Y Offline
        Y Offline
        Yaswanth
        wrote on last edited by
        #3

        You can create an image with the same x,y & dimensions of stackview, before stackview creates. That image will work as background.

        1 Reply Last reply
        0
        • T Tom_H

          @ivarec What color property? StackView doesn't have one. Try setting the StackView background to the ApplicationWindow background.

          I Offline
          I Offline
          ivarec
          wrote on last edited by
          #4

          @Tom_H what do you mean? Something like:

          StackView {
            background: root.background //assuming my ApplicationWindow had id "root"
          }
          

          I've tried just that and I still get the white background in my StackView.

          T 1 Reply Last reply
          0
          • GrecKoG Offline
            GrecKoG Offline
            GrecKo
            Qt Champions 2018
            wrote on last edited by
            #5

            StackView is transparent.
            Maybe the items you push onto it are not?

            I 1 Reply Last reply
            2
            • I ivarec

              @Tom_H what do you mean? Something like:

              StackView {
                background: root.background //assuming my ApplicationWindow had id "root"
              }
              

              I've tried just that and I still get the white background in my StackView.

              T Offline
              T Offline
              Tom_H
              wrote on last edited by
              #6

              @ivarec Yes, but then each Page you push onto StackView has a background property that you would also need to set. If that works then you probably wouldn't need to set the StackView background.

              1 Reply Last reply
              0
              • GrecKoG GrecKo

                StackView is transparent.
                Maybe the items you push onto it are not?

                I Offline
                I Offline
                ivarec
                wrote on last edited by
                #7

                @GrecKo you are right. I was adding a pane, and after setting its background to transparent like this:

                Pane {
                ...
                  background: Qt.transparent
                ...
                }
                

                I got the desired result. Thanks :)

                1 Reply Last reply
                0
                • I Offline
                  I Offline
                  ivarec
                  wrote on last edited by
                  #8

                  Note: it turns out that setting background to Qt.transparent doesn't make sense. It worked simply because the types are incompatible and background got set to null. It's easier to simply set background to null to get the same result.

                  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