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. QLineedit cursor jumps right in hex input
Forum Updated to NodeBB v4.3 + New Features

QLineedit cursor jumps right in hex input

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 1 Posters 887 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.
  • pauleddP Offline
    pauleddP Offline
    pauledd
    wrote on last edited by
    #1

    Hi

    I need to have a Qlineedit that accepts six hexadecimal digits as input like that:
    "FF3ABD".
    I simply used:

    setInputMask("HHHHHH");
    

    for that. The problem is if I enter the first digit the cursor jumps into an rightmost empty field which seems to be not part of my input mask.

    Peek 2021-04-23 16-06.gif

    Why is that so and can this be changed to let the cursor simply jump the the next right field?

    1 Reply Last reply
    0
    • pauleddP Offline
      pauleddP Offline
      pauledd
      wrote on last edited by
      #2

      I think I solved it by using a QValidator instead of inputMask:

      le = new QLineEdit(this);
      QRegExp rx("([0-9]|[A-F]|[a-f]){6}");
      QValidator *valid = new QRegExpValidator(rx,this);
      le->setValidator(valid);
      

      and to always get uppercase chars when typing I added this:

      connect(le,&QLineEdit::textChanged,this,&mainwindow::textEdited);
      ...
      void mainwindow::textEdited(const QString &arg1)
      {
          le->setText(arg1.toUpper());
      }
      

      Peek 2021-04-24 08-59.gif

      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