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. How do I subclass QDial to show notches values ?
Forum Updated to NodeBB v4.3 + New Features

How do I subclass QDial to show notches values ?

Scheduled Pinned Locked Moved Solved General and Desktop
39 Posts 2 Posters 13.6k 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.
  • mrjjM Offline
    mrjjM Offline
    mrjj
    Lifetime Qt Champion
    wrote on last edited by mrjj
    #28

    hi
    Not tested myself.
    option.rect should control where QDial is
    and the normal rect is your widget.

    So if u set option.rect before
    p.drawComplex

    U should be able to move it around?

    PuntP 1 Reply Last reply
    0
    • mrjjM mrjj

      hi
      Not tested myself.
      option.rect should control where QDial is
      and the normal rect is your widget.

      So if u set option.rect before
      p.drawComplex

      U should be able to move it around?

      PuntP Offline
      PuntP Offline
      Punt
      wrote on last edited by
      #29

      @mrjj
      Look, if I

      option.rect.setX(20)
      

      this is just moving one part of the QDial --'
      Gyazo

      And what do you mean about the normal rect ?

      The only rect I have is option.rect no ?!

      mrjjM 1 Reply Last reply
      0
      • PuntP Punt

        @mrjj
        Look, if I

        option.rect.setX(20)
        

        this is just moving one part of the QDial --'
        Gyazo

        And what do you mean about the normal rect ?

        The only rect I have is option.rect no ?!

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

        @Punt
        Option has rect yes, used for the drawComplexControl call.
        You own widget, also has rect, simply called rect or this->rect
        which is the real area since the QDial is just painted.

        PuntP 1 Reply Last reply
        0
        • mrjjM mrjj

          @Punt
          Option has rect yes, used for the drawComplexControl call.
          You own widget, also has rect, simply called rect or this->rect
          which is the real area since the QDial is just painted.

          PuntP Offline
          PuntP Offline
          Punt
          wrote on last edited by
          #31

          @mrjj

              rect().setRect(0,0,200,200);
              option.rect.setRect(30,30,100,100);
              p.drawText(120,120,"(120,120)");
              p.drawText(30,30,"(30,30)");
              p.drawText(200,200,"(200,200)");
          

          => Gyazo

          I don't find anything to move ticks ...

          mrjjM 1 Reply Last reply
          0
          • PuntP Punt

            @mrjj

                rect().setRect(0,0,200,200);
                option.rect.setRect(30,30,100,100);
                p.drawText(120,120,"(120,120)");
                p.drawText(30,30,"(30,30)");
                p.drawText(200,200,"(200,200)");
            

            => Gyazo

            I don't find anything to move ticks ...

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

            Hmm
            so it dont use option.rect() for the tick drawing.
            Strange.

            Alternatively
            new a layout
            set to your widget
            New a QDial
            add to layout
            adjust layout margins to get room for text.
            Paint the text in paintEvent.
            Remove the drawComplexControl etc.

            PuntP 1 Reply Last reply
            0
            • mrjjM mrjj

              Hmm
              so it dont use option.rect() for the tick drawing.
              Strange.

              Alternatively
              new a layout
              set to your widget
              New a QDial
              add to layout
              adjust layout margins to get room for text.
              Paint the text in paintEvent.
              Remove the drawComplexControl etc.

              PuntP Offline
              PuntP Offline
              Punt
              wrote on last edited by
              #33

              @mrjj
              In my subclass ?

              mrjjM 1 Reply Last reply
              0
              • PuntP Punt

                @mrjj
                In my subclass ?

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

                @Punt
                Yes
                In constructor
                so it becomes a composite widget with a normal QDial inside.
                You will also have to create some public signal to use from outside
                since you cannot directly connect to the QDail.

                mrjjM 1 Reply Last reply
                0
                • mrjjM mrjj

                  @Punt
                  Yes
                  In constructor
                  so it becomes a composite widget with a normal QDial inside.
                  You will also have to create some public signal to use from outside
                  since you cannot directly connect to the QDail.

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

                  Hi
                  yes that seems to be possible.

                  https://www.dropbox.com/s/5hjry2pcb0mpsi2/myqdial.zip?dl=0
                  I just did it in Creator for test. Using code in
                  CustomDial is smarter.

                  PuntP 1 Reply Last reply
                  0
                  • mrjjM mrjj

                    Hi
                    yes that seems to be possible.

                    https://www.dropbox.com/s/5hjry2pcb0mpsi2/myqdial.zip?dl=0
                    I just did it in Creator for test. Using code in
                    CustomDial is smarter.

                    PuntP Offline
                    PuntP Offline
                    Punt
                    wrote on last edited by
                    #36

                    @mrjj

                    Sorry was busy...
                    I don't understand how to do it..
                    I tried, when I want to use layout() this is crashing.. I tried different things but isn't working, I'm tired of this button x)

                    mrjjM 1 Reply Last reply
                    0
                    • PuntP Punt

                      @mrjj

                      Sorry was busy...
                      I don't understand how to do it..
                      I tried, when I want to use layout() this is crashing.. I tried different things but isn't working, I'm tired of this button x)

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

                      @Punt
                      Np.
                      Did u try test?
                      U must create layout first with new
                      and assign to ur widget
                      else
                      layout() returns null.
                      something like
                      QVBoxLayou *verticalLayout = new QVBoxLayout(this);
                      verticalLayout->setContentsMargins(32, 32, 32, 32);
                      QDial *dial = new QDial(this); ** might have this as class memeber
                      verticalLayout->addWidget(dial);

                      PuntP 1 Reply Last reply
                      0
                      • mrjjM mrjj

                        @Punt
                        Np.
                        Did u try test?
                        U must create layout first with new
                        and assign to ur widget
                        else
                        layout() returns null.
                        something like
                        QVBoxLayou *verticalLayout = new QVBoxLayout(this);
                        verticalLayout->setContentsMargins(32, 32, 32, 32);
                        QDial *dial = new QDial(this); ** might have this as class memeber
                        verticalLayout->addWidget(dial);

                        PuntP Offline
                        PuntP Offline
                        Punt
                        wrote on last edited by Punt
                        #38

                        @mrjj said:

                        @Punt
                        Np.
                        Did u try test?
                        U must create layout first with new
                        and assign to ur widget
                        else
                        layout() returns null.
                        something like
                        QVBoxLayou *verticalLayout = new QVBoxLayout(this);
                        verticalLayout->setContentsMargins(32, 32, 32, 32);
                        QDial *dial = new QDial(this); ** might have this as class memeber
                        verticalLayout->addWidget(dial);

                        Ok that worked, thanks bro ! now I'll add my texts where I want :)

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

                          super!
                          You might need to surface some of the signals from the QDial to make
                          it do anything usefull.

                          In this regards , please note that u -can- connect signals to signals
                          So you can define some new public signals and hook the new signals
                          to the QDial signals.
                          From outside u can then connect to the new signals.

                          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