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. Connecting two sliders manually?
Forum Updated to NodeBB v4.3 + New Features

Connecting two sliders manually?

Scheduled Pinned Locked Moved Solved General and Desktop
connectqslider
20 Posts 4 Posters 4.4k 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 mrjj
    8 Aug 2018, 16:48

    @lansing
    hmm yes, seems to take 3 ticks regardless.
    Its handled here

    void QAbstractSlider::wheelEvent(QWheelEvent * e)
    {
        Q_D(QAbstractSlider);
        e->ignore();
        int delta = e->delta();
        if (e->inverted())
            delta = -delta;
        if (d->scrollByDelta(e->orientation(), e->modifiers(), delta))
            e->accept();
    }
    

    so maybe it depends on how mwheel is setup.

    L Offline
    L Offline
    lansing
    wrote on 8 Aug 2018, 19:50 last edited by
    #11

    @mrjj

    Ok now I got into a QSlider paradox...

    I created the slider object in the ui, then I created a new slider subclass base on QAbstractSlider. Then in the ui I tried to promote the slider object to the new subclass, but in the "base class" selection, it doesn't have QAbstractSlider as a choice, so I chose "QSlider" and the program ended complaining about constructor doesn't match. But I have to use QAbstractSlider as the base class because Qslider doesn't have control for wheelEvent.

    M 1 Reply Last reply 8 Aug 2018, 20:07
    0
    • L lansing
      8 Aug 2018, 19:50

      @mrjj

      Ok now I got into a QSlider paradox...

      I created the slider object in the ui, then I created a new slider subclass base on QAbstractSlider. Then in the ui I tried to promote the slider object to the new subclass, but in the "base class" selection, it doesn't have QAbstractSlider as a choice, so I chose "QSlider" and the program ended complaining about constructor doesn't match. But I have to use QAbstractSlider as the base class because Qslider doesn't have control for wheelEvent.

      M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 8 Aug 2018, 20:07 last edited by
      #12

      @lansing
      Are you sure ctor do match ?

      L 1 Reply Last reply 8 Aug 2018, 20:18
      0
      • M mrjj
        8 Aug 2018, 20:07

        @lansing
        Are you sure ctor do match ?

        L Offline
        L Offline
        lansing
        wrote on 8 Aug 2018, 20:18 last edited by
        #13

        @mrjj

        It complains about setTickInterval being not a member of the class

        Here's my new slider header

        class NewSlider: public QAbstractSlider
        {
        public:
            NewSlider(QWidget * parent = nullptr);
        }
        
        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 8 Aug 2018, 20:20 last edited by
          #14

          Hi,

          Why inheriting from QAbstractSlider if you want to customise QSlider ?

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

          L 1 Reply Last reply 8 Aug 2018, 20:30
          1
          • S SGaist
            8 Aug 2018, 20:20

            Hi,

            Why inheriting from QAbstractSlider if you want to customise QSlider ?

            L Offline
            L Offline
            lansing
            wrote on 8 Aug 2018, 20:30 last edited by
            #15

            @SGaist

            Hi, because QSlider doesn't have access to wheelEvent, which is one of the thing I need.

            M 1 Reply Last reply 8 Aug 2018, 20:33
            0
            • L lansing
              8 Aug 2018, 20:30

              @SGaist

              Hi, because QSlider doesn't have access to wheelEvent, which is one of the thing I need.

              M Offline
              M Offline
              mrjj
              Lifetime Qt Champion
              wrote on 8 Aug 2018, 20:33 last edited by
              #16

              @lansing
              Hi
              QSlider also have
              void wheelEvent(QWheelEvent * e)
              you can just override it. (its a virtual function )

              1 Reply Last reply
              0
              • S Offline
                S Offline
                SGaist
                Lifetime Qt Champion
                wrote on 8 Aug 2018, 20:33 last edited by
                #17

                I understand you want to reimplement the wheelEvent method but inheriting from QAbstractSlider means that you're going to reimplement also the painting, etc. to make your custom slider match the design of QSlider. On the other hand, subclassing QSlider and reimplement the wheelEvent there will reduce highly the work needed.

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

                1 Reply Last reply
                1
                • L Offline
                  L Offline
                  lansing
                  wrote on 8 Aug 2018, 20:54 last edited by
                  #18

                  Oh it does have a wheelEvent...I was looking at the document and I couldn't find the word on the page, so I thought it doesn't have.

                  http://doc.qt.io/qt-5/qslider.html

                  M 1 Reply Last reply 8 Aug 2018, 21:00
                  0
                  • S Offline
                    S Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on 8 Aug 2018, 20:56 last edited by
                    #19

                    When in doubt look at the base class(s) implementation and/or the link named List of all members, including inherited members.

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

                    1 Reply Last reply
                    2
                    • L lansing
                      8 Aug 2018, 20:54

                      Oh it does have a wheelEvent...I was looking at the document and I couldn't find the word on the page, so I thought it doesn't have.

                      http://doc.qt.io/qt-5/qslider.html

                      M Offline
                      M Offline
                      mrjj
                      Lifetime Qt Champion
                      wrote on 8 Aug 2018, 21:00 last edited by
                      #20

                      @lansing
                      Pro Tip. ;)

                      If you right click your custom class name
                      alt text

                      You can easy see and insert functions from base

                      alt text

                      1 Reply Last reply
                      3

                      20/20

                      8 Aug 2018, 21:00

                      • Login

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