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. Problem with central widget and style sheet
Forum Updated to NodeBB v4.3 + New Features

Problem with central widget and style sheet

Scheduled Pinned Locked Moved General and Desktop
10 Posts 3 Posters 7.5k 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.
  • C Offline
    C Offline
    clepto
    wrote on last edited by
    #1

    Hello, i have a problem

    you can see the problem in the videos below, in the first video i don't set style sheet to my central widget

    http://ubuntuone.com/3dly9V6LCwPBWMjnMYxcdr

    in the second video i set style sheet to my central widget

    http://ubuntuone.com/4lyf6EEaAmWL8DWS6N44Gi

    the style sheet i set is a backgound image
    @QWidget#mainwidget {
    background-image: url(/home/chris/.config/coyote/themes/dark/images/general_background.png);
    }@

    i have set mainwidget as ObjectName to the widget

    the problem as you can see is that when i set style sheet the other styles sheets at the other widgets doesn't change
    also the background of the central widgets doesn't change accordind to the image

    any idea?

    1 Reply Last reply
    0
    • T Offline
      T Offline
      tucnak
      wrote on last edited by
      #2

      Your way won't working. If you use Qt Designer - you can select centralWidget and add dynamic value to it (green cross at Object Inspector topbar) with bool value - true. And in your .qss:
      @
      QWidget[somevalueiaddedbefore=true] {
      background-image: url("/home/chris/.config/coyote/themes/dark/images/general_background.png");
      /* or /
      background-image: url(":/themes/dark/images/generalBackground.png"); /
      qrc-way */
      }
      @
      But I recommend you to use resources instead of full way (like the second way). Read about resources on the Net.

      UPD: Or you can do simply, just use objectName as ID:
      @
      QWidget#centralWidget {
      background-image: url("/home/chris/.config/coyote/themes/dark/images/general_background.png");
      }
      @

      1 Reply Last reply
      0
      • C Offline
        C Offline
        clepto
        wrote on last edited by
        #3

        i am not using qt designer so i can't use the first method.
        i am already using objectName as ID

        @QWidget#mainwidget@ from the code in my first post

        any idea?

        1 Reply Last reply
        0
        • C Offline
          C Offline
          clepto
          wrote on last edited by
          #4

          I can't understand why the centralWidget's background doesn't change..

          1 Reply Last reply
          0
          • V Offline
            V Offline
            vezprog
            wrote on last edited by
            #5

            My suggestion would be to get other forms of a stylesheets working on your central widget first...go to the designer, click on your central widget in the object list, and click the stylesheet interface. Add this line:

            @
            #centralWidget {
            color: rgb(85, 255, 0);
            }
            @

            or if its name is mainWidget then
            @
            #mainWidget {
            color: rgb(85, 255, 0);
            }
            @

            See if your button text colors changes...if so, then its something wrong with your stylesheet command. I just tried it and it worked for me.

            1 Reply Last reply
            0
            • C Offline
              C Offline
              clepto
              wrote on last edited by
              #6

              with the color it works

              so there is a problem with my style sheet, hmm, i tried moving my image in the project's folder but nothing

              just a correction, for the backgound color the style sheet needs to be
              @#centralWidget {
              background-color: rgb(85, 255, 0);
              }
              @ :)

              1 Reply Last reply
              0
              • V Offline
                V Offline
                vezprog
                wrote on last edited by
                #7

                As I said above, that should change the text color on the button. Not the background color.

                1 Reply Last reply
                0
                • C Offline
                  C Offline
                  clepto
                  wrote on last edited by
                  #8

                  i don't have any buttons, the central widget is a widget contain the final layout of my application so that i can use QMainWindow.setCentralWidget()

                  1 Reply Last reply
                  0
                  • V Offline
                    V Offline
                    vezprog
                    wrote on last edited by
                    #9

                    Ok, well I was just clearly stating you should try something else out other than the style sheet you used to error check you previous configuration, buttons or no buttons, text or no text.

                    Good luck.

                    1 Reply Last reply
                    0
                    • C Offline
                      C Offline
                      clepto
                      wrote on last edited by
                      #10

                      thanks for your help, with a search a see that generally there is a problem with centralwidget/mainwindow and background image

                      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