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. Customized QScrollBar
Forum Updated to NodeBB v4.3 + New Features

Customized QScrollBar

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 3 Posters 698 Views 2 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.
  • M Offline
    M Offline
    mahd96
    wrote on last edited by
    #1

    i want to customize a QScrollbar; like rounding its margins and ... .
    but i can not use StyleSheet for some reason.
    is there a way to do it? perhaps with paintevent or QPalette.

    raven-worxR 1 Reply Last reply
    0
    • M mahd96

      i want to customize a QScrollbar; like rounding its margins and ... .
      but i can not use StyleSheet for some reason.
      is there a way to do it? perhaps with paintevent or QPalette.

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      @mahd96
      no, native style internals are not accessible.
      The only thing without using stylesheets is to overrride the QScrollBar's paintEvent() to do the whole drawing yourself or by implementing a QProxyStyle and again do the painting yourself.

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      1
      • mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi
        why can't you use a stylesheet?

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mahd96
          wrote on last edited by
          #4

          i am working on a quite big application and now we start to have lots of crashes in drawEvents that are activated in paintEvents, generaly rendering seems to be issue in this case.
          we tend to replace css and stylesheet with QPalette.
          but css supports some sizing hints and i am looking to replace them. some hints like radius,ScrollbarHeight and... .

          mrjjM 1 Reply Last reply
          0
          • M mahd96

            i am working on a quite big application and now we start to have lots of crashes in drawEvents that are activated in paintEvents, generaly rendering seems to be issue in this case.
            we tend to replace css and stylesheet with QPalette.
            but css supports some sizing hints and i am looking to replace them. some hints like radius,ScrollbarHeight and... .

            mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @mahd96
            Hmm ok. What Qt version?
            I saw some reports about stylesheet and crashes for Qt5.12.
            (the bug id escapes me)

            Well the paintEvent is like

            void QSlider::paintEvent(QPaintEvent *)
            {
                Q_D(QSlider);
                QPainter p(this);
                QStyleOptionSlider opt;
                initStyleOption(&opt);
                opt.subControls = QStyle::SC_SliderGroove | QStyle::SC_SliderHandle;
                if (d->tickPosition != NoTicks)
                    opt.subControls |= QStyle::SC_SliderTickmarks;
                if (d->pressedControl) {
                    opt.activeSubControls = d->pressedControl;
                    opt.state |= QStyle::State_Sunken;
                } else {
                    opt.activeSubControls = d->hoverControl;
                }
                style()->drawComplexControl(QStyle::CC_Slider, &opt, &p, this);
            }
            

            so i fear the things you want to alter is inside drawComplexControl, however
            QStyleOptionSlider does control some of it.

            https://code.woboq.org/qt5/qtbase/src/widgets/widgets/qslider.cpp.html

            1 Reply Last reply
            2

            • Login

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