2

Here's my end goal: I want to transition between two images. I want the original image to fade out, and at the same time, the new image to fade in.

I know I need to modify the opacity, and I found this great link for "How to make Qt widgets fade in or out": How to make Qt widgets fade in or fade out?

I also know I need to set the image for the QWidget, and I found out how to do that with the following code:

m_image1 = new QWidget();
m_image1->setStyleSheet("border-image: url(\"" + m_imagePath1 + "\") 0 0 0 0 strech strech; ");

Where I'm stuck is the layout. How do I lay a QWidget directly on top of another QWidget.

I did read about QStackedWidget, and it seems like it would be useful: https://doc.qt.io/qt-5/qstackedwidget.html . There's a method to set the current widget via setCurrentIndex(int). However, it doesn't seem to allow me to be transitioning out a widget and transitioning in a widget at the same time. It just either is one widget or the other widget. And from the class description, it says "a stack of widgets where only one widget is visible at a time."

A lot of the layouts I'm aware of, position items next to each other, not on top.

So, my question is how do I stack the widgets to do a transition between the widget contents, by fading them in/out?

Thank you.

  • You say: *at the same time*, You could show a picture of what you want to get, now it's very confusing. – eyllanesc Mar 18 '19 at 03:05
  • I guess I was trying to have an effect where the image being looked at is dimmed/faded-away, introducing a new image, which will be faded in as well. So it's I envision the top image going away, and introducing the new image, underneath it. But I want to make a transition for it so it's not just one image, then the next image, but something gradual across maybe a half or one second. –  Mar 18 '19 at 03:12
  • Not sure if I could capture it in a picture. I would make a video of it if I knew how. Does that make more sense though now? –  Mar 18 '19 at 03:13
  • You believe that at any given moment the 2 images are shown in the same position and semitransparent. Do you want that effect in the images or in the widgets? – eyllanesc Mar 18 '19 at 03:27

0 Answers0