Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Background color in StackedWidget
Forum Updated to NodeBB v4.3 + New Features

Background color in StackedWidget

Scheduled Pinned Locked Moved General and Desktop
16 Posts 3 Posters 8.7k Views 1 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.
  • McLionM Offline
    McLionM Offline
    McLion
    wrote on last edited by
    #3

    AutoFillBackground is unchecked (everywhere) and not set from code either.
    Do I have to set it ... and where?

    1 Reply Last reply
    0
    • B Offline
      B Offline
      butterface
      wrote on last edited by
      #4

      For the widget on the second page it should be true.

      1 Reply Last reply
      0
      • McLionM Offline
        McLionM Offline
        McLion
        wrote on last edited by
        #5

        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.

        1 Reply Last reply
        0
        • B Offline
          B Offline
          butterface
          wrote on last edited by
          #6

          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.

          1 Reply Last reply
          0
          • McLionM Offline
            McLionM Offline
            McLion
            wrote on last edited by
            #7

            If I have AutoFillBackground checked for the widget on the second page it works with some default color, as long as I don't have any stylesheet options on this widget or the ui loaded on this page.

            1 Reply Last reply
            0
            • JKSHJ Offline
              JKSHJ Offline
              JKSH
              Moderators
              wrote on last edited by
              #8

              [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

              Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

              1 Reply Last reply
              0
              • McLionM Offline
                McLionM Offline
                McLion
                wrote on last edited by
                #9

                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)@
                1 Reply Last reply
                0
                • JKSHJ Offline
                  JKSHJ Offline
                  JKSH
                  Moderators
                  wrote on last edited by
                  #10

                  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.

                  Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                  1 Reply Last reply
                  0
                  • McLionM Offline
                    McLionM Offline
                    McLion
                    wrote on last edited by
                    #11

                    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.

                    1 Reply Last reply
                    0
                    • B Offline
                      B Offline
                      butterface
                      wrote on last edited by
                      #12

                      Maybe you can paste your piece of code here. Sometimes one cannot see the forest because of all the trees. ;)

                      1 Reply Last reply
                      0
                      • McLionM Offline
                        McLionM Offline
                        McLion
                        wrote on last edited by
                        #13

                        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!

                        1 Reply Last reply
                        0
                        • B Offline
                          B Offline
                          butterface
                          wrote on last edited by
                          #14

                          You can post the ui file from the designer or the generated header if possible.

                          1 Reply Last reply
                          0
                          • McLionM Offline
                            McLionM Offline
                            McLion
                            wrote on last edited by
                            #15

                            Is there a way to attach files to posts ?!?

                            1 Reply Last reply
                            0
                            • B Offline
                              B Offline
                              butterface
                              wrote on last edited by
                              #16

                              I don't think so. If it is too big you can maybe shape it down to just the QStackWidget parts.

                              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