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. How to make a widget like user control?
Forum Updated to NodeBB v4.3 + New Features

How to make a widget like user control?

Scheduled Pinned Locked Moved Solved Mobile and Embedded
widget
7 Posts 3 Posters 2.9k Views 3 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.
  • MhM93M Offline
    MhM93M Offline
    MhM93
    wrote on last edited by
    #1

    I make a keyboard for my embedded device that just have numbers keys.
    I have some forms( widgets) that contains multi text boxes. I want to call my keyboard widget in my forms.(not to copy paste all the buttons and all the signals and all the slots)
    How can I define my keyboard widget?
    How can I use it in my all forms?(like a button control)

    H.Ghassami

    kshegunovK 1 Reply Last reply
    0
    • MhM93M MhM93

      I make a keyboard for my embedded device that just have numbers keys.
      I have some forms( widgets) that contains multi text boxes. I want to call my keyboard widget in my forms.(not to copy paste all the buttons and all the signals and all the slots)
      How can I define my keyboard widget?
      How can I use it in my all forms?(like a button control)

      kshegunovK Offline
      kshegunovK Offline
      kshegunov
      Moderators
      wrote on last edited by
      #2

      @MhM93
      I would make the keyboard widget post the appropriate key events, for example:

      QWidget * widget = QApplication::focusWidget();
      if (widget)  {
          // 0 was pressed
          QCoreApplication::postEvent(widget, new QKeyEvent(QEvent::KeyPress, Qt::Key_0));
          QCoreApplication::postEvent(widget, new QKeyEvent(QEvent::KeyRelease, Qt::Key_0));
      }
      

      You could improve on that if you keep the widget variable throughout the application and intercept the focus changed events, so you don't need to always get the focused widget from the application.

      Kind regards.

      Read and abide by the Qt Code of Conduct

      MhM93M 1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi,

        What version of Qt are you using ?

        What about making it a virtual keyboard ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        MhM93M 1 Reply Last reply
        0
        • SGaistS SGaist

          Hi,

          What version of Qt are you using ?

          What about making it a virtual keyboard ?

          MhM93M Offline
          MhM93M Offline
          MhM93
          wrote on last edited by
          #4

          @SGaist
          Qt4.7.3
          my embedded device need virtual key board. I saw virtual keyboard in Qt. but it support release 5 (that I saw.)

          H.Ghassami

          1 Reply Last reply
          0
          • kshegunovK kshegunov

            @MhM93
            I would make the keyboard widget post the appropriate key events, for example:

            QWidget * widget = QApplication::focusWidget();
            if (widget)  {
                // 0 was pressed
                QCoreApplication::postEvent(widget, new QKeyEvent(QEvent::KeyPress, Qt::Key_0));
                QCoreApplication::postEvent(widget, new QKeyEvent(QEvent::KeyRelease, Qt::Key_0));
            }
            

            You could improve on that if you keep the widget variable throughout the application and intercept the focus changed events, so you don't need to always get the focused widget from the application.

            Kind regards.

            MhM93M Offline
            MhM93M Offline
            MhM93
            wrote on last edited by MhM93
            #5

            I made a keyboard widget and promoting it to other widget. But how can I access the parent widget and change the data by press each button in keyboard widget?

            H.Ghassami

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              That's not a good idea. You should rather take a look at the Input Panel example

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              MhM93M 1 Reply Last reply
              0
              • SGaistS SGaist

                That's not a good idea. You should rather take a look at the Input Panel example

                MhM93M Offline
                MhM93M Offline
                MhM93
                wrote on last edited by
                #7

                @SGaist : really thanks. that is exactly I want.

                H.Ghassami

                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