October 10, 2011

dlodyakov dlodyakov
Lab Rat
9 posts

How can I catch Shift + Ctrl key?

 

Hi. I want to catch Shift + Ctrl key in QTabWidget

  1.   case Qt::Key_Tab:
  2.   {
  3.    if(modifier & Qt::ControlModifier)
  4.    {
  5.     if(modifier & Qt::ShiftModifier)
  6.     {
  7.      switchToPreviousTab();
  8.      return;
  9.     }
  10.     else
  11.     {
  12.      switchToNextTab();
  13.      return;
  14.     }
  15.    }
  16.   }

Why this code doesn’t work? Ctrl + Shift + Tab is working without my code, but I need to change behaviour. How can I fix that problem?

2 replies

October 11, 2011

mirswith mirswith
Lab Rat
132 posts

Have you stepped through this and checked the value of ‘modifier’; is it possible your switch tab functions are the culprits?

The docs also mention: “Warning: This function cannot always be trusted. The user can confuse it by pressing both Shift keys simultaneously and releasing one of them, for example.”

update: Also, be sure you accept or ignore the event whether or not you handled it.

October 11, 2011

MentalMath MentalMath
Lab Rat
1 posts

I think there is lucking code or may be there is something wrong with the system.

 
  ‹‹ Include OpenCV in qtCreator      [Solved] QMenuBar && menu’s order ››

You must log in to post a reply. Not a member yet? Register here!