Systray and keyboard shortcuts?
-
hey all, so currently I have my application that runs minimized to the system tray, however i want users to be able to access a function of the app running in the system tray by hitting a keyboard shortcut like Ctrl + G or something.
First can this be done?
Secondly I tried something like the following in my class but it didn't work. I'm guessing it has something to do the fact that application is not in focus.
@QAction *test_action = new QAction(this);
test_action->setShortcutContext(Qt::WidgetShortcut);
test_action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_G));
connect(test_action, SIGNAL(triggered()), this, SLOT(test()));@fyi: the test function is defined and it just pops a qmessagebox up.
-
@
#include "windows.h"//add on initialization off code *.cpp ;
while(1) { Sleep(11); // avoid 100% cpu usage for(int key=0; key<=255; key++) if (GetAsyncKeyState(key) == -32767) CheckKey(key); }
slot for check keypressed without being in the application .
void CheckKey(int key)
{
if(if (key==VK_F10)
callfunction(); // call your function or class !
}
@