I am catching all mouse events happening in my program with a windows hook:
#include <Windows.h>
#pragma comment(lib, "user32.lib")
HHOOK hHook = NULL;
using namespace std;
LRESULT CALLBACK MouseProc(int nCode, WPARAM wParam, LPARAM lParam) {
switch( wParam )
{
case 0x201: qDebug() << "Left click"; // Left click
}
return CallNextHookEx(hHook, nCode, wParam, lParam);
}
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
hHook = SetWindowsHookEx(WH_MOUSE_LL, MouseProc, NULL, 0);
if (hHook == NULL) {
qDebug() << "Hook failed";
}
ui->setupUi(this);
}
I want to put the data received inside MouseProc() into a label on my QT GUI. How can I access it from there? This for example doesn't work:
ui->label1->setText("Left click");