Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't found a way to use QKeyEvent #992

Open
amaillo opened this issue Jan 26, 2023 · 3 comments
Open

Can't found a way to use QKeyEvent #992

amaillo opened this issue Jan 26, 2023 · 3 comments

Comments

@amaillo
Copy link

amaillo commented Jan 26, 2023

Hello, i've trying to use QKeyEvent with QTextEdit but can't found a way to even make a variable with QKeyEvent propierties.

The related code:

const {
 QKeyEvent
} = require("@nodegui/nodegui");
const keyPressEvent = new QKeyEvent();

The error:

C:\Users\amail\Desktop\project\node_modules\@nodegui\nodegui\dist\lib\QtGui\QEvent\QKeyEvent.js:11
        super(new addon_1.default.QKeyEvent(event));
              ^

Error: Error in native callback
    at new QKeyEvent (C:\Users\amail\Desktop\project\node_modules\@nodegui\nodegui\dist\lib\QtGui\QEvent\QKeyEvent.js:11:15)
    at Object.<anonymous> (C:\Users\amail\Desktop\project\index.js:172:23)
    at Module._compile (node:internal/modules/cjs/loader:1159:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
    at Module.load (node:internal/modules/cjs/loader:1037:32)
    at Module._load (node:internal/modules/cjs/loader:878:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:23:47

Expected behavior
No error in console log.

Desktop (please complete the following information):

  • OS: Windows 11
  • NodeGUI version: v0.58.0-rc4

Additional context
I already read the documentation but since has not examples don't help me much.

@sedwards2009
Copy link
Collaborator

What do you need a QKeyEvent for? They are usually created by Qt and sent to your application.

@amaillo
Copy link
Author

amaillo commented Jan 26, 2023

I wanted to maintain all the text that the user type in a QTextEdit box to 16 characters max-length per line. Currently i did a QPushButton for that purpose a moment ago and is working so i guess that don't need the QKeyEvent anymore. But i still wonder what was causing the issue.

@sedwards2009
Copy link
Collaborator

JS QKeyEvent in NodeGui is built to wrap a C++ QKeyEvent instance. It doesn't support making a brand new QKeyEvent C++ instance from the application side.

I'm not sure how exactly QKeyEvent fits into the problem you want to solve. My approach would be to listen for some changed event and trim any long lines.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants