Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. QLineEdit is overwriting the first input character (bug?)
Forum Updated to NodeBB v4.3 + New Features

QLineEdit is overwriting the first input character (bug?)

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
androidqlineeditwidgetbug
3 Posts 3 Posters 652 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.
  • H Offline
    H Offline
    Hector_WPG
    wrote on 3 Feb 2021, 13:57 last edited by
    #1

    Hello,

    I have been working with QT for and Android development.

    I have a problem with QLineEdit widgets. If the textbox is empty, because of the first time or I removed the previous text, when I write then the first character becomes highlighted so if I write another character I overwrite the first character.

    I have disabled several android features like "text-autocomplete", besides in QLineEdit property imhNonPredictiveText = true

    • Android version 9
    • QT 5.12.0 building for android_armv7

    How to reproduce:
    In a QLineEdit, remove all the characters using backspace, once it is empty, press backspace one or more times. Then write a character, it might be highlighted (selected).

    Mitigation:
    This is the way we are mitigating this problem, but we would like to if this is a known problem or a configuration problem, and how to solve it without using something like this:

    
    // QLineEdit bug fix
    connect(ui->qlineeditWidget, SIGNAL(cursorPositionChanged(int,int)), this, SLOT(resetQLineEditSelectionIssue(int,int)));
    
    
    void FrmWifiSettings::resetQLineEditSelectionIssue(int oldPos, int newPos)
    {
    	QObject * senderObj = sender();
    
    	if (senderObj != nullptr)
    	{
    		QLineEdit *widget = (QLineEdit*) senderObj;
    
    		if ( (widget != nullptr) && (oldPos == 0) && (newPos == 1) && (widget->hasSelectedText()) )
    		{
    			qDebug() << "resetQLineEditSelectionIssue() : issue found ";
    			widget->deselect();
    		}
    	}
    }
    

    Thanks

    J 1 Reply Last reply 3 Feb 2021, 14:06
    0
    • H Hector_WPG
      3 Feb 2021, 13:57

      Hello,

      I have been working with QT for and Android development.

      I have a problem with QLineEdit widgets. If the textbox is empty, because of the first time or I removed the previous text, when I write then the first character becomes highlighted so if I write another character I overwrite the first character.

      I have disabled several android features like "text-autocomplete", besides in QLineEdit property imhNonPredictiveText = true

      • Android version 9
      • QT 5.12.0 building for android_armv7

      How to reproduce:
      In a QLineEdit, remove all the characters using backspace, once it is empty, press backspace one or more times. Then write a character, it might be highlighted (selected).

      Mitigation:
      This is the way we are mitigating this problem, but we would like to if this is a known problem or a configuration problem, and how to solve it without using something like this:

      
      // QLineEdit bug fix
      connect(ui->qlineeditWidget, SIGNAL(cursorPositionChanged(int,int)), this, SLOT(resetQLineEditSelectionIssue(int,int)));
      
      
      void FrmWifiSettings::resetQLineEditSelectionIssue(int oldPos, int newPos)
      {
      	QObject * senderObj = sender();
      
      	if (senderObj != nullptr)
      	{
      		QLineEdit *widget = (QLineEdit*) senderObj;
      
      		if ( (widget != nullptr) && (oldPos == 0) && (newPos == 1) && (widget->hasSelectedText()) )
      		{
      			qDebug() << "resetQLineEditSelectionIssue() : issue found ";
      			widget->deselect();
      		}
      	}
      }
      

      Thanks

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 3 Feb 2021, 14:06 last edited by
      #2

      @Hector_WPG You should check Qt bug tracker. If it is not known issue there you can file a bug.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      A 1 Reply Last reply 3 Feb 2021, 14:24
      1
      • J jsulm
        3 Feb 2021, 14:06

        @Hector_WPG You should check Qt bug tracker. If it is not known issue there you can file a bug.

        A Offline
        A Offline
        aha_1980
        Lifetime Qt Champion
        wrote on 3 Feb 2021, 14:24 last edited by
        #3

        @jsulm That is correct, but I'd first try with the latest Qt 5 version 5.15.2

        Regards

        Qt has to stay free or it will die.

        1 Reply Last reply
        0

        2/3

        3 Feb 2021, 14:06

        • Login

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