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. Immediate Validation and editingFinished signal

Immediate Validation and editingFinished signal

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 2.5k Views
  • 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.
  • E Offline
    E Offline
    Elii
    wrote on last edited by
    #1

    Hi
    I want to do immediate validation of my edit lines. I want to tell the user immediately after he left the edit line field that the value he entered is maybe incorrect.

    So I connect the line edit with editingFinished() signal. However the problem is that the signal is not emitted when I click outside of the line edit, for example when I just click on the dialog. It is emitted when I click on some other line edit on the dialog. So I am looking for signal that is emitted everytime I click outside the edit line. How can I achieve this ?

    @connect(mLineEdit, SIGNAL(editingFinished()), this, SLOT(Validate()))

    MyDlg::Validate()
    {
    QString text = mLineEdit->text();
    bool isValid = check_if_valid(text);
    if(!isValid)
    // set the color of edit line to be red
    }@

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      Intercept the QMouseEvent from the dialog/ top level widget.

      (Z(:^

      1 Reply Last reply
      0
      • E Offline
        E Offline
        Elii
        wrote on last edited by
        #3

        You mean the
        mouseMoveEvent ( QMouseEvent * ) ?

        Also, would be ok to subclass QLineEdit and override
        leaveEvent ( QEvent * ) instead ?

        1 Reply Last reply
        0
        • sierdzioS Offline
          sierdzioS Offline
          sierdzio
          Moderators
          wrote on last edited by
          #4

          Mouse move is invoked a bit too often for your use case, but you can use it if you want. Mouse click event would be better. The leave event also seems good, if not the best in this situation.

          (Z(:^

          1 Reply Last reply
          0
          • T Offline
            T Offline
            terenty
            wrote on last edited by
            #5

            Hi! Have you considered "QLineEdit::setValidator":http://doc-snapshot.qt-project.org/4.8/qlineedit.html#setValidator ?

            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