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. InputMask and SetCursorPosition
QtWS25 Last Chance

InputMask and SetCursorPosition

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 645 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.
  • yczoY Offline
    yczoY Offline
    yczo
    wrote on last edited by
    #1

    Hello folks, I have a QLineEdit with an input mask:

    ui->r5->setInputMask("HHHHHHHH"); 
    const QString v5aux2 = "[ 0-9,A-F]{7}";
    const QString v5aux1 = "[ 0-1]{1}";
    const QString v5 = v5aux1 + v5aux2;
    QRegExp v5E(v5);
    ui->r5->setValidator(new QRegExpValidator(v5E,this));
    

    The problem is that whenever I make click with the mouse, the cursor goes the mouse position.

    I know the command ui->r5->setCursorPosition(0);
    but, for the QLineEdit is not a slot called clicked()

    Then, how can i set the cursor to 0?

    Any help will wellcommed
    Thanks in advance
    Greetings

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

      @yczo said:

      QLineEdit

      You can subclass it and override mousePress
      or use event filter and capture the event

      http://www.qtcentre.org/threads/43273-Event-filter-with-mouse-events

      and
      void MyEdit::mouseMoveEvent(QMouseEvent *e)
      {
      if(e->buttons() == Qt::LeftButton)
      ..
      }

      1 Reply Last reply
      2

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved