Skip to content
QtWS25 Last Chance
  • QKeyPress - Simulating key press

    Solved General and Desktop qkeyevent qt 5.7
    4
    0 Votes
    4 Posts
    4k Views
    Z
    @sayan275 Dear Sayan I think you may know the answer to my problem. I'm struggling to send a self-defined event from main.cpp to the ui->boardView in mainwindow.cpp, as the ui->boardView is only defined in mainwindow.cpp. Yet the eventfilter can only be installed on the ui->boardView. It seems you've done similar sth similar. Could you please tell me how to realize such feature? (there are also detailed code about this which I put on stackoverflow https://stackoverflow.com/questions/60424216/how-to-use-eventfilter-under-child-widget-to-catch-self-define-event)
  • handle KeyEvent in C++

    Solved QML and Qt Quick keyevent qkeyevent
    3
    0 Votes
    3 Posts
    2k Views
    B
    thanks, I missed it because I usually used QQmlEngine or something alike and not a QQuickView.
  • QKeyEvent and child

    Unsolved General and Desktop qkeyevent
    8
    0 Votes
    8 Posts
    2k Views
    Andy314A
    Hi @Vincent, I use a barcode scanner for my app, too. All works without problem for me. Did you try to input the "key events" in a simple text editor of you OS. Which characters compared to the editor are missing in Qt ?
  • 0 Votes
    4 Posts
    3k Views
    SGaistS
    The Keyboard Focus in Widgets chapter from Qt's documentation already give some hints on how to handle that. If you build your focus chain properly you can then use nextInFocusChain and previousInFocusChain to avoid hardcoding stuff.
  • Keyboard key emulation from C++ to QML

    Solved General and Desktop qml qkeyevent
    6
    0 Votes
    6 Posts
    4k Views
    RiteshPanchalR
    Thanks for the Reply. I get everything working from below changes. UART.cpp UART::UART(QObject *parent) : QObject(parent) { m_engine = (QQmlApplicationEngine *)parent; } void UART::readRequest() { QKeyEvent key_press(QKeyEvent::KeyPress, Qt::Key_P, Qt::NoModifier); QCoreApplication::sendEvent(m_engine->rootObjects().first(), &key_press); } UART.h class UART : public QObject { Q_OBJECT public: explicit UART(QObject *parent = 0); signals: protected: public slots: void UARTInit(); private: QQmlApplicationEngine *m_engine; private slots: void readRequest(); }; And main.cpp without any change as per your previous reply. Thanks ... :)
  • 0 Votes
    1 Posts
    989 Views
    No one has replied
  • 0 Votes
    6 Posts
    5k Views
    F
    Anyway solved it. I needed to call grabKeyboard function from the MainWindow class, so this->grabKeyboard() is the line I needed to add when key_0 button is pressed so that MainWindow doesn't lose the keyboard focus, and then when released I needed to add the line this->releaseKeyboard() to resume normal behaviour, that is, other widgets can have the keyboard focus.
  • not able to sendevent from keyboard notification

    Unsolved Mobile and Embedded embedded arm qkeyevent
    2
    0 Votes
    2 Posts
    2k Views
    SGaistS
    Hi, Because usually, it's the central widget of a QMainWindow that will have the keyboard focus thus get the keyPress/Release etc. events. You can put an event filter on that widget to do what you want. Hope it helps
  • 0 Votes
    2 Posts
    1k Views
    JeroentjehomeJ
    You need to accept the event so the parent knows that the event has been handled. Otherwise the event will go all children until someone accepts it or if none do, it will be ignored. so keyEv->accept() should do the trick.