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. qt receive msg from remote contral device in smart tv

qt receive msg from remote contral device in smart tv

Scheduled Pinned Locked Moved Solved Mobile and Embedded
8 Posts 3 Posters 1.8k 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.
  • A Offline
    A Offline
    Alex_wang
    wrote on 10 Apr 2017, 09:36 last edited by
    #1

    Qt How to identify key information from the remote control?
    It is Similar to a mouse or keyboard.
    qt receive the key info from the device E.g 'up' or 'ok', then ui responses

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 10 Apr 2017, 21:05 last edited by
      #2

      Hi,

      You should give more information:

      • What smart TV ?
      • How is the remote handling by the OS running on the device ?
      • What OS is running on the device ?
      • Version of Qt ?
        etc.

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

      1 Reply Last reply
      0
      • A Offline
        A Offline
        Alex_wang
        wrote on 11 Apr 2017, 01:16 last edited by Alex_wang 4 Nov 2017, 01:19
        #3

        Hi,
        the tv remote contral device
        http://www.easyicon.net/1188524-TV_Remote_icon.html
        The remote contral device can contral the tv ui by the key 'up','down','ok','right','left'.

        I 'm not focus on the communication between the device with qt and the remote contral device,
        but the qt's responses for the key 'up' from the remote contral device.
        example:
        qt can handle the 'up' key from the keyboard and ui responses ,then the focus moves up.
        so, qt how handle the 'up' key from the remote contral device similarly?

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 11 Apr 2017, 19:46 last edited by
          #4

          Do you realise that you are asking how Qt handles a device without giving any information about the actual device, how it is seen by the system and such vital information.

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

          A 1 Reply Last reply 12 Apr 2017, 00:44
          0
          • S SGaist
            11 Apr 2017, 19:46

            Do you realise that you are asking how Qt handles a device without giving any information about the actual device, how it is seen by the system and such vital information.

            A Offline
            A Offline
            Alex_wang
            wrote on 12 Apr 2017, 00:44 last edited by
            #5

            @SGaist
            two steps:

            1. the device with qt receive the info from the tv remote controller
              2.qt handle and response the info
              first have achieved.
              the second is my focus and question.

            now,I have a idea :
            similar with virtual keyboard, qt uses the ```
            sendEvent(QObject *receiver,QEvent *event)

            example :```
            QKeyEvent upKey(QEvent::KeyPress, Qt::Key_Up, Qt::NoModifier);
            QCoreApplication::sendEvent(your_widget, &leftKey);
            ``
            J 1 Reply Last reply 12 Apr 2017, 05:13
            0
            • A Alex_wang
              12 Apr 2017, 00:44

              @SGaist
              two steps:

              1. the device with qt receive the info from the tv remote controller
                2.qt handle and response the info
                first have achieved.
                the second is my focus and question.

              now,I have a idea :
              similar with virtual keyboard, qt uses the ```
              sendEvent(QObject *receiver,QEvent *event)

              example :```
              QKeyEvent upKey(QEvent::KeyPress, Qt::Key_Up, Qt::NoModifier);
              QCoreApplication::sendEvent(your_widget, &leftKey);
              ``
              J Online
              J Online
              jsulm
              Lifetime Qt Champion
              wrote on 12 Apr 2017, 05:13 last edited by
              #6

              @Alex_wang "the device with qt receive the info from the tv remote controller" - what does this mean? Does your device receive the event or are you already able to get the event in your Qt app? You should really explain better, else it is hard to understand what is working and what not.

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

              A 1 Reply Last reply 12 Apr 2017, 06:22
              0
              • J jsulm
                12 Apr 2017, 05:13

                @Alex_wang "the device with qt receive the info from the tv remote controller" - what does this mean? Does your device receive the event or are you already able to get the event in your Qt app? You should really explain better, else it is hard to understand what is working and what not.

                A Offline
                A Offline
                Alex_wang
                wrote on 12 Apr 2017, 06:22 last edited by
                #7

                @jsulm
                change the question:
                How simulate the key press event by Qt and use it in JavaScript of QML?

                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  Alex_wang
                  wrote on 12 Apr 2017, 10:45 last edited by
                  #8

                  my solution:

                  CKeyEvent.h

                  class CKeyEvent : public QObject
                  {
                      Q_OBJECT
                  
                      Q_ENUMS(CKEY_ID)
                  
                  public:
                      enum CKEY_ID
                      {
                          CKEY_UP = Qt::Key_Up,
                          CKEY_DOWN= Qt::Key_Down,
                          CKEY_MAX
                      };
                      CKeyEvent(QObject *parent = NULL);
                      ~CKeyEvent();
                  
                      Q_INVOKABLE void sendCkeyPressEvent(QObject* receiver,Qt::Key CkeyId);
                      Q_INVOKABLE void sendCkeyReleaseEvent(QObject* receiver,Qt::Key CkeyId);
                  
                  private:
                      QObject* m_receiver;
                  };
                  

                  CKeyEvent.cpp

                  CKeyEvent::CKeyEvent(QObject *parent):QObject(parent)
                  {
                  
                  }
                  CKeyEvent::~CKeyEvent()
                  {
                  
                  }
                  
                  void CKeyEvent::sendCkeyPressEvent(QObject* receiver,Qt::Key CkeyId)
                  {
                      QKeyEvent keyPressEvent(QEvent::KeyPress, CkeyId, Qt::NoModifier);
                      QGuiApplication::sendEvent(receiver, &keyPressEvent);
                  }
                  void CKeyEvent::sendCkeyReleaseEvent(QObject* receiver,Qt::Key CkeyId)
                  {
                      QKeyEvent keyReleaseEvent(QEvent::KeyRelease, CkeyId, Qt::NoModifier);
                      QGuiApplication::sendEvent(receiver, &keyReleaseEvent);
                  }
                  

                  main.cpp

                  /int main(int argc, char *argv[])
                  {
                      QGuiApplication app(argc, argv);
                      QQmlApplicationEngine engine;
                  
                      CKeyEvent *Ckey = new CKeyEvent();
                      engine.rootContext()->setContextProperty("cKeyCDP",Ckey);
                      engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
                  
                      return app.exec();
                  }
                  

                  QML:main.qml

                  Window {
                      id : mainWindows
                      visible: true
                      width: 1024
                      height: 768
                      title: qsTr("Hello World")
                  
                      KeyFocus
                      {
                          id : keyFocus;
                      }
                  
                      Button
                      {
                          id :keyUp
                          anchors.top:keyFocus.top
                          anchors.topMargin: 20
                          anchors.left : keyFocus.right
                          anchors.leftMargin: 20
                          width: 100
                          height: 60
                  
                          text: qsTr("up")
                  
                          onClicked:
                          {
                              cKeyCDP.sendCkeyPressEvent(mainWindows,Qt.Key_Up);
                              cKeyCDP.sendCkeyReleaseEvent(mainWindows,Qt.Key_Up);
                          }
                  
                      }
                      Button
                      {
                          id :keyDown
                          anchors.top:keyUp.bottom
                          anchors.topMargin: 20
                          anchors.left : keyFocus.right
                          anchors.leftMargin: 20
                          width: 100
                          height: 60
                  
                          text: qsTr("down")
                          onClicked:
                          {
                              cKeyCDP.sendCkeyPressEvent(mainWindows,Qt.Key_Down);
                              cKeyCDP.sendCkeyReleaseEvent(mainWindows,Qt.Key_Down);
                          }
                      }
                  }
                  
                  1 Reply Last reply
                  0

                  5/8

                  12 Apr 2017, 00:44

                  • Login

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