Results 1 to 4 of 4

Thread: on_LineEditX_textChanged()

  1. #1
    Join Date
    Jan 2009
    Posts
    78
    Thanks
    21
    Thanked 1 Time in 1 Post

    Default on_LineEditX_textChanged()

    Hi!
    I have some lineEdits in a form among other:
    lineEdit1, lineEdit2, lineEdit3 ...

    I implemented a member function to be executed when any of them are edited:
    on_lineEdit1_textChanged(), on_lineEdit2_textChanged(), on_lineEdit3_textChanged() ...

    They all have the same code, because the textChanged event validates the content of all lineEdits in that set and performs some calculations with their content if all are valid.

    The question is if there is a way to control the "textChanged" in a set of lineEdits without having to do what i "tried" to describe above?

    Thanks in advance.

  2. #2
    Join Date
    Mar 2008
    Posts
    141
    Thanks
    10
    Thanked 9 Times in 9 Posts

    Default Re: on_LineEditX_textChanged()

    Hi,

    there is something like a signalmapper. But I haven't used it.

  3. The following user says thank you to janus for this useful post:

    gt.beta2 (5th February 2009)

  4. #3
    Join Date
    Jan 2009
    Posts
    78
    Thanks
    21
    Thanked 1 Time in 1 Post

    Default Re: on_LineEditX_textChanged()

    Thanks
    I will take a look at it!

  5. #4
    Join Date
    Dec 2007
    Posts
    19
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: on_LineEditX_textChanged()

    You can connect the signal emitted by the lineedits manually to one singe slot.

    In your class definition:
    private slot:
    void checkLineEdit();
    Then you connect all your signals to the slot in the constructor

    connect(ui.lineEdit1, SIGNAL(textChanged()), this, SLOT(checkLineEdit());
    In the slot you can then get the object which emmited the signal using the sender function():

    QLineEdit* lineEdit = qobject_cast<QLineEdit*>(sender());

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.