Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
qtws26_logo

The Qt Event of the Year: Qt World Summit 2026

Save Your Spot >
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to connect a Qslider to a QPoint for changing the point position in a QScatterSeries?
Qt 6.12 LTS is out! See what's new in the release blog

How to connect a Qslider to a QPoint for changing the point position in a QScatterSeries?

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 1.5k Views
  • 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.
  • amir.sanaatA Offline
    amir.sanaatA Offline
    amir.sanaat
    wrote on last edited by
    #1

    Hello, everyone, I wanna to change the position of a point (which was defined by QPoint) by using a slide bar (based on Qslider).
    I want the point position in x-axes changed when the slidebar changed.
    how can i do?

    really appreciate it

    jsulmJ 1 Reply Last reply
    0
    • amir.sanaatA amir.sanaat

      Hello, everyone, I wanna to change the position of a point (which was defined by QPoint) by using a slide bar (based on Qslider).
      I want the point position in x-axes changed when the slidebar changed.
      how can i do?

      really appreciate it

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @amir.sanaat The slider has doc.qt.io/qt-5/qabstractslider.html#sliderMoved signal. Connect a slot to it and update the x coordinate of your point accordingly.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • amir.sanaatA Offline
        amir.sanaatA Offline
        amir.sanaat
        wrote on last edited by
        #3

        Dear @jsulm
        I really approciate it for your reply.
        As I am not a Qt expert, I couldn't understand your answer.
        Actually, I create a slider called slider1 and point (315,4) in QScatterSeries

        QScatterSeries *series1 = new QScatterSeries();
        series1->setName("power");
        series1->append(315,4);
        QSlider *slider1 = new QSlider(Qt::Horizontal,0);

        how can I connect these to by signal and slot?

        jsulmJ 1 Reply Last reply
        0
        • amir.sanaatA amir.sanaat

          Dear @jsulm
          I really approciate it for your reply.
          As I am not a Qt expert, I couldn't understand your answer.
          Actually, I create a slider called slider1 and point (315,4) in QScatterSeries

          QScatterSeries *series1 = new QScatterSeries();
          series1->setName("power");
          series1->append(315,4);
          QSlider *slider1 = new QSlider(Qt::Horizontal,0);

          how can I connect these to by signal and slot?

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @amir.sanaat If you're not familiar with signals/slots then you should first learn how they work as they are one of the core concepts in Qt. See http://doc.qt.io/qt-5/signalsandslots.html
          I assume here that the code you posted is located in MainWindow:

          MainWindow::MainWindow(...)
          {
              // You should declare series1 as member variable to be able to access it later
              series1 = new QScatterSeries();
              series1->setName("power");
              series1->append(315,4);
              QSlider *slider1 = new QSlider(Qt::Horizontal,0);
              connect(slider, &QSlider::sliderMoved, this, MainWindow::onSliderMoved);
          }
          
          void MainWindow::onSliderMoved(int value)
          {
              // Change here the position
          }

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          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
          • Unsolved