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. Custom QWidget Keyboard first time click issue.
Forum Updated to NodeBB v4.3 + New Features

Custom QWidget Keyboard first time click issue.

Scheduled Pinned Locked Moved Unsolved General and Desktop
27 Posts 5 Posters 5.4k 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.
  • D Offline
    D Offline
    deleted372
    wrote on last edited by
    #13

    It may be a silly question, does it happen with all the buttons of your keyboard?
    Are you sure that the first time you push on a button of your keyboard the slot keyboardHandler() gets called?

    A 1 Reply Last reply
    0
    • D deleted372

      It may be a silly question, does it happen with all the buttons of your keyboard?
      Are you sure that the first time you push on a button of your keyboard the slot keyboardHandler() gets called?

      A Offline
      A Offline
      Arvind K
      wrote on last edited by
      #14

      @JoZCaVaLLo

      Yes, it happens with all the buttons of a keyboard. slot keyboardHandler() does not get called for the first time. another thing I observed that when I called a keyboard on QPushbutton clicked event then keyboard works properly. this issue happens with QlineEdit Only.

      1 Reply Last reply
      0
      • D Offline
        D Offline
        deleted372
        wrote on last edited by
        #15

        I would call lineEditkeyboard->setLineEdit(line) only when the lineEdit gets the focus.
        In addition, in the setLineEdit(), I would call this->setFocusProxy(line). In order to avoid your keyboard to steal the focus from your linedit.

        A 1 Reply Last reply
        0
        • D deleted372

          I would call lineEditkeyboard->setLineEdit(line) only when the lineEdit gets the focus.
          In addition, in the setLineEdit(), I would call this->setFocusProxy(line). In order to avoid your keyboard to steal the focus from your linedit.

          A Offline
          A Offline
          Arvind K
          wrote on last edited by
          #16

          @JoZCaVaLLo
          @mrjj
          @J-Hilk
          @dheerendra
          one more thing to share when I called keyboard widget with a show() like
          lineEditkeyboard->setLineEdit(line);
          lineEditkeyboard->show();

          the keyboard works properly but when I called Keyboard like

          lineEditkeyboard->setLineEdit(line);
          lineEditkeyboard->setWindowModality(Qt::ApplicationModal);
          lineEditkeyboard->show();

          then I face the same issue of the first click.

          mrjjM 1 Reply Last reply
          0
          • A Arvind K

            @JoZCaVaLLo
            @mrjj
            @J-Hilk
            @dheerendra
            one more thing to share when I called keyboard widget with a show() like
            lineEditkeyboard->setLineEdit(line);
            lineEditkeyboard->show();

            the keyboard works properly but when I called Keyboard like

            lineEditkeyboard->setLineEdit(line);
            lineEditkeyboard->setWindowModality(Qt::ApplicationModal);
            lineEditkeyboard->show();

            then I face the same issue of the first click.

            mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on last edited by
            #17

            @Arvind-K
            hi, we need to find out what is happening.
            please do
            qDebug() << "focus widget " << qApp->focusObject();
            which tells us when you open the keyboard, who has focus.
            Meaning who will get the keys if u type.
            I think you have something that steals keyboard focus when u open the
            lineEditkeyboard

            A 1 Reply Last reply
            0
            • mrjjM mrjj

              @Arvind-K
              hi, we need to find out what is happening.
              please do
              qDebug() << "focus widget " << qApp->focusObject();
              which tells us when you open the keyboard, who has focus.
              Meaning who will get the keys if u type.
              I think you have something that steals keyboard focus when u open the
              lineEditkeyboard

              A Offline
              A Offline
              Arvind K
              wrote on last edited by
              #18

              @mrjj

              as you said I have done same when keyboard widget is shown.
              output is

              DBG default: focus widget QLineEdit(0x227ca90, name = "lineEdit")

              lineEdit is Nothing but the QLineEdit on Keyboard widget.

              mrjjM 1 Reply Last reply
              0
              • A Arvind K

                @mrjj

                as you said I have done same when keyboard widget is shown.
                output is

                DBG default: focus widget QLineEdit(0x227ca90, name = "lineEdit")

                lineEdit is Nothing but the QLineEdit on Keyboard widget.

                mrjjM Offline
                mrjjM Offline
                mrjj
                Lifetime Qt Champion
                wrote on last edited by
                #19

                @Arvind-K
                Ok so it does have the focus when first click is not registered?

                A 1 Reply Last reply
                0
                • mrjjM mrjj

                  @Arvind-K
                  Ok so it does have the focus when first click is not registered?

                  A Offline
                  A Offline
                  Arvind K
                  wrote on last edited by
                  #20

                  @mrjj

                  Yes.
                  after that when I click on Anywhere on Widget Nothing happen or no Any event gets called.

                  mrjjM 1 Reply Last reply
                  0
                  • A Arvind K

                    @mrjj

                    Yes.
                    after that when I click on Anywhere on Widget Nothing happen or no Any event gets called.

                    mrjjM Offline
                    mrjjM Offline
                    mrjj
                    Lifetime Qt Champion
                    wrote on last edited by
                    #21

                    @Arvind-K
                    so the widget appear frozen for a moment ?
                    Do you have any kind of loops in constructor or anything like that ?

                    A 1 Reply Last reply
                    0
                    • mrjjM mrjj

                      @Arvind-K
                      so the widget appear frozen for a moment ?
                      Do you have any kind of loops in constructor or anything like that ?

                      A Offline
                      A Offline
                      Arvind K
                      wrote on last edited by
                      #22

                      @mrjj

                      No, there is no Loop in the constructor or No Any other code only I have connected signal to Slot.

                      Keyboard::Keyboard(QWidget *parent) :
                      QWidget(parent),
                      ui(new Ui::Keyboard)
                      {
                      ui->setupUi(this);

                      this->setWindowFlags(Qt::WindowStaysOnTopHint);
                      connect ( ui->Buttonq, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) );
                      connect ( ui->Buttonw, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) );
                      connect ( ui->Buttone, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) );
                      connect ( ui->Buttonr, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) );
                      connect ( ui->Buttont, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) );
                      connect ( ui->Buttony, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) );
                      connect ( ui->Buttonu, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) );
                      connect ( ui->Buttoni, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) );
                      connect ( ui->Buttono, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) );
                      connect ( ui->Buttonp, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) );
                      
                      connect ( ui->Buttona, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) );
                      connect ( ui->Buttons, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) );
                      connect ( ui->Buttond, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) );
                      connect ( ui->Buttonf, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) );
                      connect ( ui->Buttong, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) );
                      connect ( ui->Buttonh, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) );
                      connect ( ui->Buttonj, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) );
                      connect ( ui->Buttonk, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) );
                      connect ( ui->Buttonl, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) );
                      connect ( ui->Buttonz, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) );
                      connect ( ui->Buttonx, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) );
                      connect ( ui->Buttonc, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) );
                      connect ( ui->Buttonv, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) );
                      connect ( ui->Buttonb, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) );
                      connect ( ui->Buttonn, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) );
                      connect ( ui->Buttonm, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) );
                      connect ( ui->Button0, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) );
                      connect ( ui->Button1, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) );
                      connect ( ui->Button2, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) );
                      connect ( ui->Button3, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) );
                      connect ( ui->Button4, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) );
                      connect ( ui->Button5, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) );
                      connect ( ui->Button6, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) );
                      connect ( ui->Button7, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) );
                      connect ( ui->Button8, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) );
                      connect ( ui->Button9, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) );
                      connect ( ui->space, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) );
                      
                      outputText = "";
                      shift = false;
                      

                      }

                      mrjjM 1 Reply Last reply
                      0
                      • A Arvind K

                        @mrjj

                        No, there is no Loop in the constructor or No Any other code only I have connected signal to Slot.

                        Keyboard::Keyboard(QWidget *parent) :
                        QWidget(parent),
                        ui(new Ui::Keyboard)
                        {
                        ui->setupUi(this);

                        this->setWindowFlags(Qt::WindowStaysOnTopHint);
                        connect ( ui->Buttonq, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) );
                        connect ( ui->Buttonw, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) );
                        connect ( ui->Buttone, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) );
                        connect ( ui->Buttonr, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) );
                        connect ( ui->Buttont, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) );
                        connect ( ui->Buttony, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) );
                        connect ( ui->Buttonu, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) );
                        connect ( ui->Buttoni, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) );
                        connect ( ui->Buttono, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) );
                        connect ( ui->Buttonp, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) );
                        
                        connect ( ui->Buttona, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) );
                        connect ( ui->Buttons, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) );
                        connect ( ui->Buttond, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) );
                        connect ( ui->Buttonf, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) );
                        connect ( ui->Buttong, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) );
                        connect ( ui->Buttonh, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) );
                        connect ( ui->Buttonj, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) );
                        connect ( ui->Buttonk, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) );
                        connect ( ui->Buttonl, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) );
                        connect ( ui->Buttonz, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) );
                        connect ( ui->Buttonx, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) );
                        connect ( ui->Buttonc, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) );
                        connect ( ui->Buttonv, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) );
                        connect ( ui->Buttonb, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) );
                        connect ( ui->Buttonn, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) );
                        connect ( ui->Buttonm, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) );
                        connect ( ui->Button0, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) );
                        connect ( ui->Button1, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) );
                        connect ( ui->Button2, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) );
                        connect ( ui->Button3, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) );
                        connect ( ui->Button4, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) );
                        connect ( ui->Button5, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) );
                        connect ( ui->Button6, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) );
                        connect ( ui->Button7, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) );
                        connect ( ui->Button8, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) );
                        connect ( ui->Button9, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) );
                        connect ( ui->space, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) );
                        
                        outputText = "";
                        shift = false;
                        

                        }

                        mrjjM Offline
                        mrjjM Offline
                        mrjj
                        Lifetime Qt Champion
                        wrote on last edited by
                        #23

                        @Arvind-K
                        ok. when this situation is happening.
                        Does the buttons show activated effect ?
                        I mean can u see u pres them or anything ?

                        A 1 Reply Last reply
                        0
                        • A Offline
                          A Offline
                          Arvind K
                          wrote on last edited by
                          #24

                          @mrjj

                          As I mentioned Previously when I set WindowModality of Keyboard widget to QApplicationModal I face this First Click issue otherwise it works fine. but if I didn't set windowModality then Keyboard goes back to the parent widget.

                          **lineEditkeyboard->setWindowModality(Qt::ApplicationModal); **

                          mrjjM 1 Reply Last reply
                          0
                          • A Arvind K

                            @mrjj

                            As I mentioned Previously when I set WindowModality of Keyboard widget to QApplicationModal I face this First Click issue otherwise it works fine. but if I didn't set windowModality then Keyboard goes back to the parent widget.

                            **lineEditkeyboard->setWindowModality(Qt::ApplicationModal); **

                            mrjjM Offline
                            mrjjM Offline
                            mrjj
                            Lifetime Qt Champion
                            wrote on last edited by
                            #25

                            Hmm.
                            The code looks ok fine and i cant see any reason for
                            QApplicationModal to cause this effect but
                            it could be a bug in Qt.

                            1 Reply Last reply
                            0
                            • mrjjM mrjj

                              @Arvind-K
                              ok. when this situation is happening.
                              Does the buttons show activated effect ?
                              I mean can u see u pres them or anything ?

                              A Offline
                              A Offline
                              Arvind K
                              wrote on last edited by
                              #26

                              @mrjj

                              I can't see press button effect for the first time.

                              mrjjM 1 Reply Last reply
                              0
                              • A Arvind K

                                @mrjj

                                I can't see press button effect for the first time.

                                mrjjM Offline
                                mrjjM Offline
                                mrjj
                                Lifetime Qt Champion
                                wrote on last edited by
                                #27

                                @Arvind-K
                                Ok, then it seems its stuck for a moment in the event loop.
                                Im not sure what to do about that.
                                setWindowModality(Qt::ApplicationModal) must use a local even loop to make
                                it modal so might be a but with this or something i dont see in the code.

                                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