Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Slider movement
Forum Updated to NodeBB v4.3 + New Features

Slider movement

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
7 Posts 3 Posters 1.9k 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.
  • S Offline
    S Offline
    Sushma_MP
    wrote on last edited by Sushma_MP
    #1

    Hi,

    I have a slider functionality in Qt, i need to update the movement of slider in QML by reading the value from Qt functionality.

    1 Reply Last reply
    0
    • p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      @Sushma_MP Set the value ?

      157

      1 Reply Last reply
      1
      • S Offline
        S Offline
        Sushma_MP
        wrote on last edited by
        #3

        yes i want to set the value to the slider developed in QML.
        how to do that...?

        mrjjM p3c0P 2 Replies Last reply
        0
        • S Sushma_MP

          yes i want to set the value to the slider developed in QML.
          how to do that...?

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

          @Sushma_MP
          Hi you should show your code with the c++ signal
          and the QML where you want to get the slider signal.

          1 Reply Last reply
          0
          • S Sushma_MP

            yes i want to set the value to the slider developed in QML.
            how to do that...?

            p3c0P Offline
            p3c0P Offline
            p3c0
            Moderators
            wrote on last edited by
            #5

            @Sushma_MP said in Slider movement:

            yes i want to set the value to the slider developed in QML.
            how to do that...?

            assign a value to value using id

            157

            1 Reply Last reply
            1
            • S Offline
              S Offline
              Sushma_MP
              wrote on last edited by
              #6

              Hi,

              Below code is to set and update the position in cpp in which am emitting signal with slider position.

              //SelectedSong.cpp

              //setPosition method
              
              void SelectedSong::setPosition(int position)
              {
                  if (qAbs(mediaplayer->position() - position) > 99)
                  {
                      mediaplayer->setPosition(position);
              
                    emit signaltogetsliderposition(position);
                  }
              }
              
              //update position method
              void SelectedSong::updatePosition(qint64 position)
              {
                  positionSlider->setValue(position);
                  QTime duration(0, position / 60000, qRound((position % 60000) / 1000.0));
              }
              
              

              I catched that signal in QML as below:

               Selectedsong{
                      id:mysong
                      onSignaltogetsliderposition:
                      {
                          console.log("signal catched...")
                      }
                  }
              

              Am creating slider in QML as fallows:

              // Creation of Slider in QML

               Slider {
                              id: control
                              value: 0.0
              
                              background: Rectangle {
                                  x: control.leftPadding
                                  y: control.topPadding + control.availableHeight / 2 - height / 2
                                  implicitWidth: music_main_rect.width/2
                                  implicitHeight: music_main_rect.height/50
                                  width: control.availableWidth
                                  height: implicitHeight
                                  radius: 4
                                  //color: "#474647"
                                  color: "#bdbebf"
              
              
                                  Rectangle {
                                      width: control.visualPosition * parent.width
                                      height: parent.height
                                      //color: "#bdbebf"
                                      color: "#5da9e9"
                                      radius: 4
                                  }
                              }
              
                              handle: Rectangle {
                                  x: control.leftPadding + control.visualPosition * (control.availableWidth - width)
                                  y: control.topPadding + control.availableHeight / 2 - height / 2
                                  implicitWidth: 26
                                  implicitHeight: 26
                                  radius: 13
                                  color: control.pressed ? "#f0f0f0" : "#f6f6f6"
                                  border.color: "#bdbebf"
                              }
                          }
              

              Problem is i am not understanding how can i set that sliderposition from cpp file to this value present in slider.

              1 Reply Last reply
              0
              • p3c0P Offline
                p3c0P Offline
                p3c0
                Moderators
                wrote on last edited by
                #7

                @Sushma_MP Can't you access Slider using its id in onSignaltogetsliderposition ?

                157

                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