Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Systray and keyboard shortcuts?

Systray and keyboard shortcuts?

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 1.9k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jnewing
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • F Offline
      F Offline
      francomartins
      wrote on last edited by
      #2

      @
      #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 !
      }
      @

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved