Background color in StackedWidget
-
For the widget on the second page it should be true.
-
Thanks a lot. That basically works.
Unfortunately, I'm stuck again. What I could not add, is some color to it. As soon as I add color with a sytlesheet to the same widget it is either not applied, or only once and then again overwritten by the image of the main page. What am I doing wrong?
I am still trying to understand the logic behind all this. -
I am not sure about that. At least you should check if your widget works with the stylesheet but background color normally works on all of them.
-
[quote author="McLion" date="1350639690"]I have a Stacked widget where I have an image loaded on the main page that is used as background for this page (styleSheet: image ...). On a second page I have another ui loaded (as class)[/quote]-Is your main page a standalone QWidget? If not, you can't apply a style sheet to it -- you'll be applying the style sheet to the whole QStackedWidget (i.e. all pages will acquire the style sheet)- Edit: I need to think more before posting... :P
-
Seems to be it.
I have applied the style sheet image directly to the first page (QWidget).
I have:
@- stacked widget- page1 (where I have applied the style sheet image)
- button ..
- button ..
...
- page2 (where I only want a plain color background)
- WebBrowser (ui, class)@
- page1 (where I have applied the style sheet image)
-
Gah, ignore my last post... of course all QStackedWidget pages are QWidgets themselves... I'm not sure what I was thinking, sorry.
But anyway, this sounds like a bug. It doesn't make sense that a style sheet applied to one widget would also transfer to other widgets (except for its children). Would you like to file a report at https://bugreports.qt-project.org ?
In the meantime, maybe you can try one of the following approaches:
Implement your first page as a separate widget, create a blank page in your original stacked widget, and promote the blank page to your new "first page".
Apply the style sheet through C++ code instead of through Designer?
I've done (1) before and can vouch that it works, but I don't know if (2) will work.
-
Thanks a lot for your suggestion .. I'll try this at a later point. I'll simply "cover" all of the background for the moment.
I am rather new to Qt (and new to C++, though experienced in C for years) and I have to finish this current project within some hours for a demo on Monday. As you could maybe see from some other post in this forum I have some more important issues to solve like the signal/slot linking to another ui that just don't works. -
Maybe you can paste your piece of code here. Sometimes one cannot see the forest because of all the trees. ;)
-
I'd happily do this .. if I'd know which parts. Because the ui has been created in Designer and not by code there's not much that can be posted to show the ui setup. That's why I tried to show the stackedWidget arrangement some post ago.
I'll implementing a "workaround" here because that's for a demo (product show) only and not for a series product.
Thanks for all of your help anyway .. it's highly appreciated! -
You can post the ui file from the designer or the generated header if possible.
-
I don't think so. If it is too big you can maybe shape it down to just the QStackWidget parts.