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 styleSheet
QtWS25 Last Chance

Problem with styleSheet

Scheduled Pinned Locked Moved Solved General and Desktop
stylesheetmusic
22 Posts 3 Posters 9.5k Views
  • 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.
  • S shahriar25
    8 Jan 2016, 07:57

    Hi,
    I set the stylesheet just for the listView but it had the same result
    this is the stylesheet I used in the picure:

    color: rgb(255, 255, 255); background-color: rgb(80, 80, 80);

    I want the user to be able to change the theme of the app. so I have some stylesheets that user chooses from them and I apply them to the mainWindow.

    But there is another problem. I set the stylesheet to the stylesheet above in the qt designer and when I run the app and I choose the stylesheet from the app look at the scrollbar:

    color: rgb(0 ,0 ,0); background-color: rgb(255, 255, 255);
    http://i63.tinypic.com/intwfa.png

    and the album comboBox's backGround is the grey color too

    D Offline
    D Offline
    Devopia53
    wrote on 8 Jan 2016, 08:16 last edited by
    #4

    @shahriar25

    Hi

    QListView {
    color: rgb(255, 255, 255);
    background-color: rgb(80, 80, 80);
    }

    1 Reply Last reply
    1
    • M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 8 Jan 2016, 08:25 last edited by
      #5

      Hi
      If you dont use a name (the type) as @Devopia53 shows,
      the style sheet is used for all on screen.
      Also the scrollbar.
      So you must exclude the scrollbar by using QListView and other typenames
      so QScrollBar is not affected.

      1 Reply Last reply
      0
      • S Offline
        S Offline
        shahriar25
        wrote on 8 Jan 2016, 08:49 last edited by
        #6

        Hi
        So if I wanted to change the styleSheet I have to change the styleSheet of the objects in the ui one by one (like QLabels and QPushBurrons) ?
        and also whaen I do:

        setStyleSheet("QMainWindow {"
        "color: rgb(255, 255, 255);"
        "background-color: rgb(80, 80, 80);"
        "}"
        "QListView {"
        "color: rgb(255, 255, 255);"
        "background-color: rgb(80, 80, 80);"
        "}");

        every where is grey except the scrollbar. can I set the scrollbar to grey?

        M 1 Reply Last reply 8 Jan 2016, 08:58
        0
        • S shahriar25
          8 Jan 2016, 08:49

          Hi
          So if I wanted to change the styleSheet I have to change the styleSheet of the objects in the ui one by one (like QLabels and QPushBurrons) ?
          and also whaen I do:

          setStyleSheet("QMainWindow {"
          "color: rgb(255, 255, 255);"
          "background-color: rgb(80, 80, 80);"
          "}"
          "QListView {"
          "color: rgb(255, 255, 255);"
          "background-color: rgb(80, 80, 80);"
          "}");

          every where is grey except the scrollbar. can I set the scrollbar to grey?

          M Offline
          M Offline
          mrjj
          Lifetime Qt Champion
          wrote on 8 Jan 2016, 08:58 last edited by mrjj 1 Aug 2016, 08:58
          #7

          Yes. If you do not want all class/widget to be affected.
          like scrollbar case.

          If they are the same settings, you can also use more names for same block

          "QMainWindow, QListView {...}"

          see here for examples
          http://doc.qt.io/qt-5.5/stylesheet-examples.html

          For scrollbar
          http://doc.qt.io/qt-4.8/stylesheet-examples.html#customizing-qscrollbar

          1 Reply Last reply
          0
          • S Offline
            S Offline
            shahriar25
            wrote on 8 Jan 2016, 10:18 last edited by
            #8

            the second page doesn't customize the scrillbars inside a QListView.
            Why not?

            M 1 Reply Last reply 8 Jan 2016, 12:23
            0
            • S shahriar25
              8 Jan 2016, 10:18

              the second page doesn't customize the scrillbars inside a QListView.
              Why not?

              M Offline
              M Offline
              mrjj
              Lifetime Qt Champion
              wrote on 8 Jan 2016, 12:23 last edited by
              #9

              @shahriar25

              you mean it does not work or ?
              "QScrollBar {
              background: gray;
              }"

              1 Reply Last reply
              0
              • S Offline
                S Offline
                shahriar25
                wrote on 8 Jan 2016, 12:29 last edited by
                #10

                No it didn't work when I set the mainwindow's stylesheet to

                QScrollBar {
                background: gray;
                }

                it looses the style and lookes like the picture I uploaded

                M 1 Reply Last reply 8 Jan 2016, 12:35
                0
                • S shahriar25
                  8 Jan 2016, 12:29

                  No it didn't work when I set the mainwindow's stylesheet to

                  QScrollBar {
                  background: gray;
                  }

                  it looses the style and lookes like the picture I uploaded

                  M Offline
                  M Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on 8 Jan 2016, 12:35 last edited by mrjj 1 Aug 2016, 12:37
                  #11

                  @shahriar25 said:
                  QScrollBar {
                  background: gray;
                  }

                  That would make the it look gray ? That is as it should be.

                  If you set a style sheet on it,
                  it will not use the rest from style.
                  So you cannot do both.

                  If you set a style sheet. it will only use stylesheet settings
                  and might forget some it got from style.
                  They are not added together. Its ALL or nothing with style sheets.

                  You cannot just change say, background. And it still used bitmaps from Style.
                  You will have to specify bitmaps in style sheet too.

                  here is how it looks in windows
                  http://postimg.org/image/y9fp1edkz/

                  1 Reply Last reply
                  0
                  • S Offline
                    S Offline
                    shahriar25
                    wrote on 8 Jan 2016, 14:14 last edited by
                    #12

                    Hi,
                    I can't Thank you enough for the answers. I did it!

                    M 1 Reply Last reply 8 Jan 2016, 14:15
                    0
                    • S shahriar25
                      8 Jan 2016, 14:14

                      Hi,
                      I can't Thank you enough for the answers. I did it!

                      M Offline
                      M Offline
                      mrjj
                      Lifetime Qt Champion
                      wrote on 8 Jan 2016, 14:15 last edited by
                      #13

                      @shahriar25
                      \o/ super :)

                      1 Reply Last reply
                      0
                      • S Offline
                        S Offline
                        shahriar25
                        wrote on 8 Jan 2016, 14:19 last edited by
                        #14

                        I have one more Question:
                        I want the listview to show "Goto File->Add To List to add files"
                        or a background text for the labels saying "Album" when its empty
                        How shold I do that?

                        M 1 Reply Last reply 8 Jan 2016, 14:51
                        0
                        • S shahriar25
                          8 Jan 2016, 14:19

                          I have one more Question:
                          I want the listview to show "Goto File->Add To List to add files"
                          or a background text for the labels saying "Album" when its empty
                          How shold I do that?

                          M Offline
                          M Offline
                          mrjj
                          Lifetime Qt Champion
                          wrote on 8 Jan 2016, 14:51 last edited by
                          #15

                          @shahriar25 said:
                          well for the list view, you could have a start item saying that.
                          And then you then add thr real items, then remove it first.

                          1 Reply Last reply
                          0
                          • S Offline
                            S Offline
                            shahriar25
                            wrote on 8 Jan 2016, 15:15 last edited by
                            #16

                            Yes that works but if I wanted it tobe in the middle if the listView than what?
                            and for the QLabel?

                            M 1 Reply Last reply 8 Jan 2016, 15:18
                            0
                            • S shahriar25
                              8 Jan 2016, 15:15

                              Yes that works but if I wanted it tobe in the middle if the listView than what?
                              and for the QLabel?

                              M Offline
                              M Offline
                              mrjj
                              Lifetime Qt Champion
                              wrote on 8 Jan 2016, 15:18 last edited by
                              #17

                              @shahriar25
                              Well im not sure if you can make
                              it go to middle of the view.

                              Well for the QLabel, you can just set the text?

                              1 Reply Last reply
                              0
                              • S Offline
                                S Offline
                                shahriar25
                                wrote on 8 Jan 2016, 15:41 last edited by
                                #18

                                Yes I can but does it look good?
                                alright I will leave it empty.
                                thank you again

                                M 1 Reply Last reply 8 Jan 2016, 15:47
                                0
                                • S shahriar25
                                  8 Jan 2016, 15:41

                                  Yes I can but does it look good?
                                  alright I will leave it empty.
                                  thank you again

                                  M Offline
                                  M Offline
                                  mrjj
                                  Lifetime Qt Champion
                                  wrote on 8 Jan 2016, 15:47 last edited by mrjj 1 Aug 2016, 16:00
                                  #19

                                  @shahriar25
                                  well QLabel can show html so it can look pretty much as you like
                                  http://doc.qt.io/qt-5.5/richtext-html-subset.html
                                  Color and font wise.

                                  1 Reply Last reply
                                  0
                                  • S Offline
                                    S Offline
                                    shahriar25
                                    wrote on 8 Jan 2016, 16:43 last edited by
                                    #20

                                    I did it with rich text

                                    M 1 Reply Last reply 8 Jan 2016, 16:47
                                    0
                                    • S shahriar25
                                      8 Jan 2016, 16:43

                                      I did it with rich text

                                      M Offline
                                      M Offline
                                      mrjj
                                      Lifetime Qt Champion
                                      wrote on 8 Jan 2016, 16:47 last edited by
                                      #21

                                      @shahriar25
                                      So it turned out as you like?

                                      1 Reply Last reply
                                      0
                                      • S Offline
                                        S Offline
                                        shahriar25
                                        wrote on 8 Jan 2016, 17:53 last edited by
                                        #22

                                        Yes it did

                                        1 Reply Last reply
                                        0

                                        13/22

                                        8 Jan 2016, 14:15

                                        • Login

                                        • Login or register to search.
                                        13 out of 22
                                        • First post
                                          13/22
                                          Last post
                                        0
                                        • Categories
                                        • Recent
                                        • Tags
                                        • Popular
                                        • Users
                                        • Groups
                                        • Search
                                        • Get Qt Extensions
                                        • Unsolved