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. [SOLVED]Connect qlineedit with horizontal slider
Forum Updated to NodeBB v4.3 + New Features

[SOLVED]Connect qlineedit with horizontal slider

Scheduled Pinned Locked Moved General and Desktop
6 Posts 3 Posters 5.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.
  • S Offline
    S Offline
    sharon_obl82
    wrote on last edited by
    #1

    Hi,
    I want to connect lineEdit with horizontal slider that will change values when the value in lineedit changes. (picture attached)!http://i60.tinypic.com/15nq3yd.png(http://i60.tinypic.com/15nq3yd.png)!

    I have tried this method but to no avail. I wonder if it's because the value inserted into lineedit is in QString format and the value in slider is in integer format?

    cpp:
    @
    connect(ui->lineEdit_21,SIGNAL(textEdited(QString)),ui->horizontalSlider,SLOT(rag_valuechanged()));

    //in a separate function
    ru_rag = ui->lineEdit_21->text();
    int rag = ru_rag.toInt();
    //separate function ends

    int RadioUserWindow::rag_valuechanged()
    {
    int r = rag;
    ui->horizontalSlider->setValue(r);

    }
    @

    error msg:
    QObject::connect: No such slot QSlider::rag_valuechanged()
    QObject::connect: (sender name: 'lineEdit_21')
    QObject::connect: (receiver name: 'horizontalSlider')

    May I know what went wrong here?

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

      @
      connect(ui->lineEdit_21,SIGNAL(textEdited(QString)),ui->horizontalSlider,SLOT(rag_valuechanged()))
      @

      The parameters for textEdited() and rag_valuechanged() should match. So it should be rag_valuechanged(QString) and then in that slot convert the QString to integer and set it to the horizontalSlider.

      157

      1 Reply Last reply
      0
      • A Offline
        A Offline
        ankursaxena
        wrote on last edited by
        #3

        Agree with p3c0.
        It would be like this.

        connect(ui->lineEdit_21,SIGNAL(textEdited(QString)),ui->horizontalSlider, SLOT (rag_valuechanged ( QString )));

        1 Reply Last reply
        0
        • S Offline
          S Offline
          sharon_obl82
          wrote on last edited by
          #4

          i tried and i still get the same message, no such slot QSlider::rag_valuechanged(QString)

          the slider did not change when the text is changed.

          1 Reply Last reply
          0
          • A Offline
            A Offline
            ankursaxena
            wrote on last edited by
            #5

            Have you applied changes into .h file according to rag_valuechanged(QString) slot??

            If no, then I think you should define slot in .h file

            void rag_valuechanged(QString) ;

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

              i got it solved with the simpler way, right click and go to slot for lineedit and set the slider value from there without using the connect line. Thanks all.

              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