Important: Please read the Qt Code of Conduct -

Default textSelection into QLineEdit (Qt 4.8)

  • Hello,

    I have built a wigdet that contains several QLineEdit, we can navigate from QLineEdit to the other by tab touch. Text of the next QLineEdit is set by the text of into the previous QLineEdit. But the text is sytematically selected, and the function deselect() or cursorWordForward(false) are without effect.
    Some code :

    // Slot call after the signal editFinished() is emited by the previousLineEdit
    void qcustomWdg::fillLineEdit()
    QString strPreviousText = lpLineEditPrevious->text();
    // lpLineEditNext ->cursorWordBackward(true);
    // lpLineEditNext ->cursorWordForward(false);
    lpLineEditNext ->deselect();
    Executing this code places the StrPrevious intot the NextLineEdit but the text is selected. How can I do to have no selection ?

    Thank you for your help.

  • you can connect the

    @void selectionChanged()@

    signal of the QLineEdit to a custom slot,

    and than call deselect() from your slot.

  • Thank, ok this solution works but I don't understand why the code


    doesn't work

Log in to reply