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. drawControl not being called for custom styled elements

drawControl not being called for custom styled elements

Scheduled Pinned Locked Moved Unsolved General and Desktop
12 Posts 3 Posters 1.4k 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.
  • Christian EhrlicherC Christian Ehrlicher

    CC_ScrollBar is, as you can see a complex control so if you want to handle CC_ScrollBar you should override drawComplexControl()

    A Offline
    A Offline
    ateek.ujjawal
    wrote on last edited by
    #3

    @Christian-Ehrlicher I tried overriding that function as well, but it does not get called.

    Also if I wanted to draw separate elements, like the add page and sub page of the scrollbar, how would it be possible with the drawControl/drawComplexControl?

    1 Reply Last reply
    0
    • Christian EhrlicherC Online
      Christian EhrlicherC Online
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #4

      Override those functions and reimplement what you want.
      You should also make sure that you really use your style.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      A 1 Reply Last reply
      0
      • Christian EhrlicherC Christian Ehrlicher

        Override those functions and reimplement what you want.
        You should also make sure that you really use your style.

        A Offline
        A Offline
        ateek.ujjawal
        wrote on last edited by
        #5

        @Christian-Ehrlicher Tried doing that, neither the drawControl or drawComplexControl get called. What might I be doing wrong?

        Christian EhrlicherC 1 Reply Last reply
        0
        • A ateek.ujjawal

          @Christian-Ehrlicher Tried doing that, neither the drawControl or drawComplexControl get called. What might I be doing wrong?

          Christian EhrlicherC Online
          Christian EhrlicherC Online
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #6

          @ateek-ujjawal said in drawControl not being called for custom styled elements:

          What might I be doing wrong?

          You are not using your style as I already told you.

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          A 1 Reply Last reply
          1
          • Christian EhrlicherC Christian Ehrlicher

            @ateek-ujjawal said in drawControl not being called for custom styled elements:

            What might I be doing wrong?

            You are not using your style as I already told you.

            A Offline
            A Offline
            ateek.ujjawal
            wrote on last edited by
            #7

            @Christian-Ehrlicher Is this not the correct way of doing it?

              _ui.slicingScrollBar->setStyle(new CustomStyle);
            

            The slicingScrollBar is a QScrollBar. The CustomStyle is defined as follows:

            class CustomStyle : public QProxyStyle {
              Q_OBJECT
            
             public:
              CustomStyle();
              ~CustomStyle() {};
            
              void drawPrimitive(PrimitiveElement pe, const QStyleOption* opt, QPainter* p,
                                 const QWidget* widget) const override;
            
              void drawControl(ControlElement ce, const QStyleOption* opt, QPainter* p,
                               const QWidget* w = nullptr) const override;
            
              void drawComplexControl(ComplexControl cc, const QStyleOptionComplex* opt,
                                      QPainter* p,
                                      const QWidget* widget = nullptr) const override;
            };
            
            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #8

              Hi,

              What if you set it on QApplication ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              A 1 Reply Last reply
              0
              • SGaistS SGaist

                Hi,

                What if you set it on QApplication ?

                A Offline
                A Offline
                ateek.ujjawal
                wrote on last edited by
                #9

                @SGaist Still the same result.

                1 Reply Last reply
                0
                • Christian EhrlicherC Online
                  Christian EhrlicherC Online
                  Christian Ehrlicher
                  Lifetime Qt Champion
                  wrote on last edited by
                  #10

                  Start from the example in https://doc.qt.io/qt-6/qproxystyle.html#details and see what happens.

                  Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                  Visit the Qt Academy at https://academy.qt.io/catalog

                  A 1 Reply Last reply
                  1
                  • Christian EhrlicherC Christian Ehrlicher

                    Start from the example in https://doc.qt.io/qt-6/qproxystyle.html#details and see what happens.

                    A Offline
                    A Offline
                    ateek.ujjawal
                    wrote on last edited by
                    #11

                    @Christian-Ehrlicher Uh, I don't see how overriding the style hint would help. I searched the QStyle enum for options I needed and I came up with nothing useful.

                    1 Reply Last reply
                    0
                    • Christian EhrlicherC Online
                      Christian EhrlicherC Online
                      Christian Ehrlicher
                      Lifetime Qt Champion
                      wrote on last edited by
                      #12

                      You should start with this example to see if it works and then add your function to find out what is going wrong...

                      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                      Visit the Qt Academy at https://academy.qt.io/catalog

                      1 Reply Last reply
                      1

                      • Login

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