Important: Please read the Qt Code of Conduct -

Make background of Quick Controls 2 StackView transparent

  • 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.

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

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

  • @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.

  • Qt Champions 2018

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

  • @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.

  • @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 :)

  • 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.