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. [SOLVED] QLineEdit does not receive character input on Android
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] QLineEdit does not receive character input on Android

Scheduled Pinned Locked Moved Mobile and Embedded
androidkeyboardqlineedit
30 Posts 3 Posters 15.5k Views 2 Watching
  • 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.
  • S SteveMBay

    @tarod.net Yes, I tried, but its behave the same way.

    What other Qt part could influence the behavior of the QEditLine?

    T Offline
    T Offline
    tarod.net
    wrote on last edited by
    #4

    @SteveMBay Maybe the problem is your dialog window.

    Try to activate the dialog using something like this:

    // virtual override
    void MctMainDialog::showEvent( QShowEvent* showEvent )
    {
        QDialog::showEvent( showEvent);
        activateWindow();
    }
    

    "Individually, we are one drop. Together, we are an ocean."

    S 1 Reply Last reply
    0
    • T tarod.net

      @SteveMBay Maybe the problem is your dialog window.

      Try to activate the dialog using something like this:

      // virtual override
      void MctMainDialog::showEvent( QShowEvent* showEvent )
      {
          QDialog::showEvent( showEvent);
          activateWindow();
      }
      
      S Offline
      S Offline
      SteveMBay
      wrote on last edited by
      #5

      @tarod.net Okay, I'll give a try. But I have buttons for example on my dialog and they are doing fine.

      T 1 Reply Last reply
      0
      • S SteveMBay

        @tarod.net Okay, I'll give a try. But I have buttons for example on my dialog and they are doing fine.

        T Offline
        T Offline
        tarod.net
        wrote on last edited by
        #6

        @SteveMBay I'm curious. Why are you using a QDialog instead of a QWidget?

        Usually, a dialog window is a top-level window for short-term tasks and brief communications with the user.

        I've found a post which can be useful to you:

        http://stackoverflow.com/questions/2180070/qdialog-doesnt-accept-text-input-if-modal

        "Individually, we are one drop. Together, we are an ocean."

        S 1 Reply Last reply
        0
        • T tarod.net

          @SteveMBay I'm curious. Why are you using a QDialog instead of a QWidget?

          Usually, a dialog window is a top-level window for short-term tasks and brief communications with the user.

          I've found a post which can be useful to you:

          http://stackoverflow.com/questions/2180070/qdialog-doesnt-accept-text-input-if-modal

          S Offline
          S Offline
          SteveMBay
          wrote on last edited by SteveMBay
          #7

          @tarod.net Nice catch! But I am using show() and have the problem.

          About QWidget, I have a menu handler class which has more widgets and dialogs as well. I choose dialog because its a communication interface between the app end the user. Anyway, a dialog should be able to handle text input proper.
          But I am new in Qt, so I could be wrong :)

          T 1 Reply Last reply
          0
          • S SteveMBay

            @tarod.net Nice catch! But I am using show() and have the problem.

            About QWidget, I have a menu handler class which has more widgets and dialogs as well. I choose dialog because its a communication interface between the app end the user. Anyway, a dialog should be able to handle text input proper.
            But I am new in Qt, so I could be wrong :)

            T Offline
            T Offline
            tarod.net
            wrote on last edited by
            #8

            @SteveMBay Mmm. It's difficult to give you more help. Could you please show more code? I think the problem is the window or dialog which is displaying authorName.

            Also, you could try to change the QDialog and use a QWidget instead, only to check the difference.

            "Individually, we are one drop. Together, we are an ocean."

            S 1 Reply Last reply
            0
            • T tarod.net

              @SteveMBay Mmm. It's difficult to give you more help. Could you please show more code? I think the problem is the window or dialog which is displaying authorName.

              Also, you could try to change the QDialog and use a QWidget instead, only to check the difference.

              S Offline
              S Offline
              SteveMBay
              wrote on last edited by
              #9

              @tarod.net Hmm... I am thinkg about what if previously a slot was created for text change event, but already its removed.

              Is it possibble that some artifact remained somewhere that actually occure when the text changed but does nothing?

              T 1 Reply Last reply
              0
              • S SteveMBay

                @tarod.net Hmm... I am thinkg about what if previously a slot was created for text change event, but already its removed.

                Is it possibble that some artifact remained somewhere that actually occure when the text changed but does nothing?

                T Offline
                T Offline
                tarod.net
                wrote on last edited by
                #10

                @SteveMBay Well, if you connect a slot to the signal textChanged(const QString & text), do you receive data in that slot?

                "Individually, we are one drop. Together, we are an ocean."

                S 1 Reply Last reply
                0
                • T tarod.net

                  @SteveMBay Well, if you connect a slot to the signal textChanged(const QString & text), do you receive data in that slot?

                  S Offline
                  S Offline
                  SteveMBay
                  wrote on last edited by SteveMBay
                  #11

                  @tarod.net I tried all the suggestions without success...

                  • QWidget works the same
                  • textEdited() and textChanged() slots never called

                  So here are some snipplets from this class.

                  myDialog.h

                  class MctMainDialog : public QWidget
                  {
                   Q_OBJECT
                   public:
                   explicit MctMainDialog(QWidget *parent , KWDocument *document , QString url);
                   ~MctMainDialog();
                   public slot: // some button action 
                   private: // some custom private action
                   }
                  

                  myDialog.cpp : constructor

                  MyDialog::MyDialog(QWidget *parent, KWDocument *document, QString url) :
                          QWidget(parent),
                          ui(new Ui::MctMainDialog),
                          document(document),
                          fileUrl(url),
                          isEnabled(false)
                      {
                          ui->setupUi(this);
                          this->setWindowFlags(Qt::Popup| Qt::FramelessWindowHint);
                          sc = QApplication::primaryScreen();
                          sc->setOrientationUpdateMask(Qt::LandscapeOrientation | Qt::PortraitOrientation | Qt::InvertedPortraitOrientation | Qt::InvertedLandscapeOrientation);
                  
                          connect(sc, SIGNAL(orientationChanged(Qt::ScreenOrientation)), this, SLOT(orientationChanged(Qt::ScreenOrientation)));
                          connect(this, SIGNAL(start()), this, SLOT(startFunctionality()));
                          connect(this, SIGNAL(openMManager()), this, SLOT(mManager()));
                          connect(this, SIGNAL(openRManager()), this, SLOT(rManager()));        
                          connect(this, SIGNAL(clearComboBox()), ui->revComboBox, SLOT(clear()));
                  
                          ui->currentRevNumLabel->setText("0");
                      }
                  

                  I am not sure what other part of my code would be interresting. I call the constructor once in a handler class, than connect some signals and slots and thats all. Buttons, ComboBox, other signals/slots doing fine.

                  Hmm.. and from the ui code:

                    <widget class="QLineEdit" name="authorName">
                     <property name="enabled">
                      <bool>false</bool> <!-- This is the initial case, re-enabled after some action -->
                     </property>
                     <property name="text">
                      <string/>
                     </property>
                     <property name="placeholderText">
                      <string>Author</string>
                     </property>
                    </widget>
                  
                  T 1 Reply Last reply
                  0
                  • S SteveMBay

                    @tarod.net I tried all the suggestions without success...

                    • QWidget works the same
                    • textEdited() and textChanged() slots never called

                    So here are some snipplets from this class.

                    myDialog.h

                    class MctMainDialog : public QWidget
                    {
                     Q_OBJECT
                     public:
                     explicit MctMainDialog(QWidget *parent , KWDocument *document , QString url);
                     ~MctMainDialog();
                     public slot: // some button action 
                     private: // some custom private action
                     }
                    

                    myDialog.cpp : constructor

                    MyDialog::MyDialog(QWidget *parent, KWDocument *document, QString url) :
                            QWidget(parent),
                            ui(new Ui::MctMainDialog),
                            document(document),
                            fileUrl(url),
                            isEnabled(false)
                        {
                            ui->setupUi(this);
                            this->setWindowFlags(Qt::Popup| Qt::FramelessWindowHint);
                            sc = QApplication::primaryScreen();
                            sc->setOrientationUpdateMask(Qt::LandscapeOrientation | Qt::PortraitOrientation | Qt::InvertedPortraitOrientation | Qt::InvertedLandscapeOrientation);
                    
                            connect(sc, SIGNAL(orientationChanged(Qt::ScreenOrientation)), this, SLOT(orientationChanged(Qt::ScreenOrientation)));
                            connect(this, SIGNAL(start()), this, SLOT(startFunctionality()));
                            connect(this, SIGNAL(openMManager()), this, SLOT(mManager()));
                            connect(this, SIGNAL(openRManager()), this, SLOT(rManager()));        
                            connect(this, SIGNAL(clearComboBox()), ui->revComboBox, SLOT(clear()));
                    
                            ui->currentRevNumLabel->setText("0");
                        }
                    

                    I am not sure what other part of my code would be interresting. I call the constructor once in a handler class, than connect some signals and slots and thats all. Buttons, ComboBox, other signals/slots doing fine.

                    Hmm.. and from the ui code:

                      <widget class="QLineEdit" name="authorName">
                       <property name="enabled">
                        <bool>false</bool> <!-- This is the initial case, re-enabled after some action -->
                       </property>
                       <property name="text">
                        <string/>
                       </property>
                       <property name="placeholderText">
                        <string>Author</string>
                       </property>
                      </widget>
                    
                    T Offline
                    T Offline
                    tarod.net
                    wrote on last edited by tarod.net
                    #12

                    @SteveMBay Hi Steve,

                    I don't see where you are enabling authorName. When and where is the property changed?

                    BTW, I see the code isEnabled(false) in your constructor. Do you want to disable the window at the beginning?

                    "Individually, we are one drop. Together, we are an ocean."

                    S 1 Reply Last reply
                    0
                    • T tarod.net

                      @SteveMBay Hi Steve,

                      I don't see where you are enabling authorName. When and where is the property changed?

                      BTW, I see the code isEnabled(false) in your constructor. Do you want to disable the window at the beginning?

                      S Offline
                      S Offline
                      SteveMBay
                      wrote on last edited by
                      #13

                      @tarod.net
                      I have a private method to enable/disable the ui elements when the functionality is turned on. There will be the authorName enabled as well. And yes, at the beginning all ui elements of this dialog are disabled.

                      Fortunately I managed to fix it. You had almost right, inheriting from QWidget is the solution.
                      (Also, here is a related stack overflow question without answer.)

                      But I created the interface with Qt Creator and tried to manually change the base class. Unsuccessful.
                      I had a liitle time today, so recreated the entire UI in Qt Creator using QWidget, and taa-daa, it works now.

                      So, thanks for the advices!

                      T 1 Reply Last reply
                      1
                      • S SteveMBay

                        @tarod.net
                        I have a private method to enable/disable the ui elements when the functionality is turned on. There will be the authorName enabled as well. And yes, at the beginning all ui elements of this dialog are disabled.

                        Fortunately I managed to fix it. You had almost right, inheriting from QWidget is the solution.
                        (Also, here is a related stack overflow question without answer.)

                        But I created the interface with Qt Creator and tried to manually change the base class. Unsuccessful.
                        I had a liitle time today, so recreated the entire UI in Qt Creator using QWidget, and taa-daa, it works now.

                        So, thanks for the advices!

                        T Offline
                        T Offline
                        tarod.net
                        wrote on last edited by
                        #14

                        @SteveMBay Great, Steve! Good work.

                        It was a pleasure talking with you.

                        "Individually, we are one drop. Together, we are an ocean."

                        1 Reply Last reply
                        0
                        • S Offline
                          S Offline
                          SteveMBay
                          wrote on last edited by
                          #15

                          Oh, and wait a sec...
                          I forgot to add the following line:

                          this->setWindowFlags(Qt::Popup| Qt::FramelessWindowHint);
                          

                          It was neccessary becasue without it I was not able to hide my widget when other parts got focus.
                          But after I added it, the line edit went awry again...
                          I am so confused now...

                          T 1 Reply Last reply
                          0
                          • S SteveMBay

                            Oh, and wait a sec...
                            I forgot to add the following line:

                            this->setWindowFlags(Qt::Popup| Qt::FramelessWindowHint);
                            

                            It was neccessary becasue without it I was not able to hide my widget when other parts got focus.
                            But after I added it, the line edit went awry again...
                            I am so confused now...

                            T Offline
                            T Offline
                            tarod.net
                            wrote on last edited by
                            #16

                            @SteveMBay I don't understand why you need that flags. With those flags, you get a window modal and with no frame, but you are not hiding the window, aren't you?

                            Anyway, I know there are people complaining about that issue on the Internet.

                            http://stackoverflow.com/questions/7654422/no-keyboard-input-if-qlineedit-on-frameless-popup-window

                            https://forum.qt.io/topic/10115/no-keyboard-input-if-qlineedit-on-frameless-popup-window/3

                            http://www.qtcentre.org/threads/48401-QLineEdit-is-not-Editable-in-a-widget-with-X11BypassWindowManagerHint-flag

                            http://stackoverflow.com/questions/2180070/qdialog-doesnt-accept-text-input-if-modal

                            Try with setWindowFlags(Qt::X11BypassWindowManagerHint | Qt::Popup);

                            "Individually, we are one drop. Together, we are an ocean."

                            S 1 Reply Last reply
                            1
                            • T tarod.net

                              @SteveMBay I don't understand why you need that flags. With those flags, you get a window modal and with no frame, but you are not hiding the window, aren't you?

                              Anyway, I know there are people complaining about that issue on the Internet.

                              http://stackoverflow.com/questions/7654422/no-keyboard-input-if-qlineedit-on-frameless-popup-window

                              https://forum.qt.io/topic/10115/no-keyboard-input-if-qlineedit-on-frameless-popup-window/3

                              http://www.qtcentre.org/threads/48401-QLineEdit-is-not-Editable-in-a-widget-with-X11BypassWindowManagerHint-flag

                              http://stackoverflow.com/questions/2180070/qdialog-doesnt-accept-text-input-if-modal

                              Try with setWindowFlags(Qt::X11BypassWindowManagerHint | Qt::Popup);

                              S Offline
                              S Offline
                              SteveMBay
                              wrote on last edited by SteveMBay
                              #17

                              @tarod.net Definitely, I have the same issue. At the beginning I did not know that was caused by the flags.
                              I tried your suggestion - and also called activateWindow() right after using show() - but still no input operation.

                              If I dont use the flags the widget wont disappear after I touch the surrounding area.

                              T 1 Reply Last reply
                              0
                              • S SteveMBay

                                @tarod.net Definitely, I have the same issue. At the beginning I did not know that was caused by the flags.
                                I tried your suggestion - and also called activateWindow() right after using show() - but still no input operation.

                                If I dont use the flags the widget wont disappear after I touch the surrounding area.

                                T Offline
                                T Offline
                                tarod.net
                                wrote on last edited by tarod.net
                                #18

                                @SteveMBay Which flag is the "bad guy" here? Qt::Popup or Qt::FramelessWindowHint?

                                "Individually, we are one drop. Together, we are an ocean."

                                S 1 Reply Last reply
                                0
                                • T tarod.net

                                  @SteveMBay Which flag is the "bad guy" here? Qt::Popup or Qt::FramelessWindowHint?

                                  S Offline
                                  S Offline
                                  SteveMBay
                                  wrote on last edited by
                                  #19

                                  @tarod.net I just wanted to write. :) It isn't a "back & white" situation.

                                  Qt::Popup is the "bad" who prevents to use the QLineEdit but it is the "good" as well, because it allows the background to get input (and this hides my widget). As I've read in the Qt doc other flags prevent the background to get any input.

                                  T 1 Reply Last reply
                                  0
                                  • S SteveMBay

                                    @tarod.net I just wanted to write. :) It isn't a "back & white" situation.

                                    Qt::Popup is the "bad" who prevents to use the QLineEdit but it is the "good" as well, because it allows the background to get input (and this hides my widget). As I've read in the Qt doc other flags prevent the background to get any input.

                                    T Offline
                                    T Offline
                                    tarod.net
                                    wrote on last edited by
                                    #20

                                    @SteveMBay Sorry, Steve, but I don't understand well the situation.

                                    • When you say "background", you mean another window which is showing your MctMainDialog class?
                                    • The widget you mention, is the MctMainDialog class you showed some days ago?
                                    • You say the widget won't disappear after you touch the surrounding area, but if you detect a touching event, you could hide the widget or window using the functions provided by Qt, couldn't you?

                                    "Individually, we are one drop. Together, we are an ocean."

                                    S 1 Reply Last reply
                                    0
                                    • T tarod.net

                                      @SteveMBay Sorry, Steve, but I don't understand well the situation.

                                      • When you say "background", you mean another window which is showing your MctMainDialog class?
                                      • The widget you mention, is the MctMainDialog class you showed some days ago?
                                      • You say the widget won't disappear after you touch the surrounding area, but if you detect a touching event, you could hide the widget or window using the functions provided by Qt, couldn't you?
                                      S Offline
                                      S Offline
                                      SteveMBay
                                      wrote on last edited by
                                      #21

                                      @tarod.net Sorry, my English isn't the best.

                                      • Yes, the "background" is a main window (my application is a text editor) and this widget is like a dropdown menu, where I can setup many things.
                                      • Yes, we are talking the same widget that was QDialog before, but I recreated and now it is a QWidget. (Now called MctWidget, and yes, the name was misleading, it was "main" because it had some child dialogs as well.)
                                      • Maybe :) My (really) main window contains a tool handler object which owns the formatting and configuring dialogs and widgets.

                                      Now I am trying :

                                      1. to override focusInEvent() on this ReallyMainWindow
                                      2. focusInEvent() emits a signal that connected to ToolHandler
                                      3. ToolHandler gets a new slot: where calls this->mctWidget->hide()
                                      S 1 Reply Last reply
                                      0
                                      • S SteveMBay

                                        @tarod.net Sorry, my English isn't the best.

                                        • Yes, the "background" is a main window (my application is a text editor) and this widget is like a dropdown menu, where I can setup many things.
                                        • Yes, we are talking the same widget that was QDialog before, but I recreated and now it is a QWidget. (Now called MctWidget, and yes, the name was misleading, it was "main" because it had some child dialogs as well.)
                                        • Maybe :) My (really) main window contains a tool handler object which owns the formatting and configuring dialogs and widgets.

                                        Now I am trying :

                                        1. to override focusInEvent() on this ReallyMainWindow
                                        2. focusInEvent() emits a signal that connected to ToolHandler
                                        3. ToolHandler gets a new slot: where calls this->mctWidget->hide()
                                        S Offline
                                        S Offline
                                        SteveMBay
                                        wrote on last edited by
                                        #22

                                        @SteveMBay In theory, this should work, but ReallyMainWindow's focusInEvent() never called... :(

                                        T 1 Reply Last reply
                                        0
                                        • S SteveMBay

                                          @SteveMBay In theory, this should work, but ReallyMainWindow's focusInEvent() never called... :(

                                          T Offline
                                          T Offline
                                          tarod.net
                                          wrote on last edited by tarod.net
                                          #23

                                          @SteveMBay Thank you for your answers! :)

                                          Why don't you set MctWidget as modal

                                          setWindowModality(Qt::WindowModal);

                                          and add a button to close this child window?

                                          If you implement that, MctWidget will remain opened until the user clicks the close button, but you will have more control to avoid wrong behaviours.

                                          The line this->setWindowFlags(Qt::Popup| Qt::FramelessWindowHint); should be removed if you like the idea.

                                          About focusInEvent, try with this instead:

                                          bool ReallyMainWindow::event(QEvent *e) {
                                          {
                                              if (e->type() == QEvent::WindowActivate) {
                                                  // window was activated
                                              }
                                              return QWidget::event(e);
                                          }
                                          

                                          "Individually, we are one drop. Together, we are an ocean."

                                          S 1 Reply Last reply
                                          1

                                          • Login

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