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. Pass Variable in Slot when selection changes In LineEdit
Forum Updated to NodeBB v4.3 + New Features

Pass Variable in Slot when selection changes In LineEdit

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 1.1k 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.
  • P Offline
    P Offline
    praveen0991kr
    wrote on last edited by
    #1

    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 :

    Regard

    Praveen

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Maybe QSignalMapper might be useful

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • dheerendraD Offline
        dheerendraD Offline
        dheerendra
        Qt Champions 2022
        wrote on last edited by
        #3

        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 ?

        Dheerendra
        @Community Service
        Certified Qt Specialist
        http://www.pthinks.com

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          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)));@

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          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