Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. SIGNAL AND SLOT
Qt 6.12 LTS is out! See what's new in the release blog

SIGNAL AND SLOT

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 3.3k 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    I want to connect this two variables sampTime,sigFreq by using the spinbox or slider using the signal slot technique

    for ( int i=0; i<101; ++i)
    {
    x[i] = isampTime;
    y[i] = sin(2
    3.14sigFreqx[i]);
    }

    i tried something like this
    connect(ui->doubleSpinBox, SIGNAL(valueChanged(double)),sampFreq,SLOT(displayValue(double)));

    connect(ui->customPlot, SIGNAL(valueChanged(double)), ui->customPlot->graph(0),SLOT(valueChanged(double));

    PLS suggest how to do this

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

      Did you take a look at "this":http://doc.qt.digia.com/qt/signalsandslots.html tutorial?

      You can connect only object which derive from QObject ( Since Qt5 if I know correctly it does no longer need to be QObject).

      but correct syntax:
      @connect(ui->doubleSpinBox, SIGNAL(valueChanged(double)), receiver, SLOT(methodName(double)));@

      Receiver can be this if your working in the same class (QMainWindow probably).
      When value in spin box is changed, it will be "sent" to you method. From there you can do further processing.

      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

        thanks for reply
        but what will come on the place of methodName() if i have to make a slot method myself because spinbox do not have any such methods

        [quote author="Jake007" date="1356776769"]Did you take a look at "this":http://doc.qt.digia.com/qt/signalsandslots.html tutorial?

        You can connect only object which derive from QObject ( Since Qt5 if I know correctly it does no longer need to be QObject).

        but correct syntax:
        @connect(ui->doubleSpinBox, SIGNAL(valueChanged(double)), receiver, SLOT(methodName(double)));@

        Receiver can be this if your working in the same class (QMainWindow probably).
        When value in spin box is changed, it will be "sent" to you method. From there you can do further processing. [/quote]

        1 Reply Last reply
        0
        • ? Offline
          ? Offline
          A Former User
          wrote on last edited by
          #4

          Yes.

          in your class
          @
          class MyMainWindow : QMainWindow
          {
          //...
          public slots:
          void onSpinBoxChange(double var); // make sure that arguments are the same as in the signals method.
          //...
          };

          void MyMainWindow::onSpinBoxChange(double var)
          {
          // Your code to execute when value is changed.
          }
          @

          1 Reply Last reply
          0
          • ? Offline
            ? Offline
            A Former User
            wrote on last edited by
            #5

            thanks a lot.

            [quote author="Jake007" date="1356777920"]Yes.

            in your class
            @
            class MyMainWindow : QMainWindow
            {
            //...
            public slots:
            void onSpinBoxChange(double var); // make sure that arguments are the same as in the signals method.
            //...
            };

            void MyMainWindow::onSpinBoxChange(double var)
            {
            // Your code to execute when value is changed.
            }
            @[/quote]

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