Important: Please read the Qt Code of Conduct -

Pass Variable in Slot when selection changes In LineEdit

  • Hello All,
    I have to pass a variable as the line Selection Changed () What should I do ; I am stuck in the same
    pls Some one ;take me out of this problem;

    I have No. of LineSelection and I have to pass diffrent Value on each selection changed:
    Till now I am doing like that as I mention below :

    void Class1::on_lEdit1_selectionChanged()
    { OpenFn(1); }
    void Class_1::on_lEdit2_selectionChanged()
    { OpenFn(2); }
    void Class_1::on_lEdit3_selectionChanged()
    { OpenFn(3); }
    void Class_1::on_lEdit4_selectionChanged()
    { OpenFn(4);}

    How to pass value values from connect:
    It is possible to pass Value from Signal Slot :-

    I have tried like that :

    connect(ui->lEdit1,SIGNAL(selectionchanged()),this,SLOT( OpenFn(1)));
    connect(ui->lEdit2,SIGNAL(selectionchanged()),this,SLOT( OpenFn(2)));

    and so no for N lineselection:

    but it is not working giving an error

    Any hint is Appreciable :



  • Lifetime Qt Champion


    Maybe QSignalMapper might be useful

  • Qt Champions 2017

    It is possible to pass the data across the signal and slot. In this particular case of selectionChanged(), signal is does not have any argument. So it is not possible to pass the values.

    What is the value you would like to pass ? From where this value is coming ?

  • Lifetime Qt Champion

    More accurately, passing a parameter when connecting is not possible. You connect two compatible methods. Compatible means:

    • Same signature e.g.

    @connect(myButton, SIGNAL(toggled(bool)), SLOT(onToggled(bool)));@

    • Slot has less arguments but signature is still matching (from left to right) e.g.

    @connect(myObject, SIGNAL(mySignal(QString, bool)), SLOT(onMySignal(QString)));@

Log in to reply