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. QScrollBar Stylesheet not working with Qt 5.3.1
QtWS25 Last Chance

QScrollBar Stylesheet not working with Qt 5.3.1

Scheduled Pinned Locked Moved General and Desktop
7 Posts 2 Posters 2.7k 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.
  • J Offline
    J Offline
    JK_IKA
    wrote on last edited by
    #1

    Hello,
    I found a strange behavior of my styled scrollbar under Qt 5.3.1. It seems that the stylesheet for the QScrollBar is not working. It always shows the default windows-styled scrollbar. I also checked the example stylesheet for the QScrollBar from the Qt 5 documentation, no success!
    All my other stylesheets are working with 5.3.1 its just the stylesheet for QScrollBars that don't work for me!

    If I compile the same code with Qt 5.2.1 everything works fine.

    Is this a bug in Qt 5.3.1? Does anyone else have this problem?

    Thanks,
    JK_IKA

    1 Reply Last reply
    0
    • Chris KawaC Online
      Chris KawaC Online
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Works ok for me. How (and on what) do you set your stylesheet?

      1 Reply Last reply
      0
      • J Offline
        J Offline
        JK_IKA
        wrote on last edited by
        #3

        I inherited from QTableView and then set the following stylesheet with setStyleSheet()
        @QString QtExampleScrollBarStylesheet = "QScrollBar:horizontal {"
        "border: 2px solid grey;"
        "background: #32CC99;"
        "height: 15px;"
        "margin: 0px 20px 0 20px;"
        "}"
        "QScrollBar::handle:horizontal {"
        "background: white;"
        "min-width: 20px;"
        "}"
        "QScrollBar::add-line:horizontal {"
        "border: 2px solid grey;"
        "background: #32CC99;"
        "width: 20px;"
        "subcontrol-position: right;"
        "subcontrol-origin: margin;"
        "}"

        "QScrollBar::sub-line:horizontal {"
        "border: 2px solid grey;"
        "background: #32CC99;"
        "width: 20px;"
        "subcontrol-position: left;"
        "subcontrol-origin: margin;"
        "}"

        "QScrollBar:vertical {"
        "border: 2px solid grey;"
        "background: #32CC99;"
        "width: 15px;"
        "margin: 22px 0 22px 0;"
        "}"
        "QScrollBar::handle:vertical {"
        "background: white;"
        "min-height: 20px;"
        "}"
        "QScrollBar::add-line:vertical {"
        "border: 2px solid grey;"
        "background: #32CC99;"
        "height: 20px;"
        "subcontrol-position: bottom;"
        "subcontrol-origin: margin;"
        "}"

        "QScrollBar::sub-line:vertical {"
         "border: 2px solid grey;"
         "background: #32CC99;"
         "height: 20px;"
         "subcontrol-position: top;"
         "subcontrol-origin: margin;"
        "}"
        "QScrollBar::up-arrow:vertical, QScrollBar::down-arrow:vertical {"
         "border: 2px solid grey;"
         "width: 3px;"
         "height: 3px;"
         "background: white;"
        "}"
        
        "QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical {"
         "background: none;"
        "}"
        

        ;@

        1 Reply Last reply
        0
        • Chris KawaC Online
          Chris KawaC Online
          Chris Kawa
          Lifetime Qt Champion
          wrote on last edited by
          #4

          That works for me. Maybe you mixed some library files versions?

          1 Reply Last reply
          0
          • J Offline
            J Offline
            JK_IKA
            wrote on last edited by
            #5

            No, don't think so, just Qt 5.3.1 installed on the laptop, Qt 5.2.1 runs on my PC (both Win7). All other stylesheets are working only the QScrollBox doesn't.
            I tested it on a linux machine, too, same result.
            There is also no compile warning!
            Can it somehow come from the compiler? I'm using msvc2012 on PC and on laptop and linux mingw?

            1 Reply Last reply
            0
            • Chris KawaC Online
              Chris KawaC Online
              Chris Kawa
              Lifetime Qt Champion
              wrote on last edited by
              #6

              I've tested it with VS2013 and MinGW 4.8.2 on a Windows 8.1 machine. Both work ok. I don't see how compiler could matter.
              Is it the same if you run a minimal example or is it just in your app? Try this
              @QApplication a(argc, argv);
              QScrollArea w;
              w.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
              w.setStyleSheet(" ... ");
              w.show();
              return a.exec();@

              1 Reply Last reply
              0
              • J Offline
                J Offline
                JK_IKA
                wrote on last edited by
                #7

                The compiler is the only difference besides the Qt version!
                As I said, the stylesheet for QScrollBoxes works fine for Qt versions < 5.3!

                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