Skip to main content
panduvittala
Inspiring
June 11, 2014
Question

Qt in AI Panel on MAC: Keyboard events/focus issue

  • June 11, 2014
  • 3 replies
  • 2624 views

My plugin has panels that use Qt for UI, runs fine on windows. But on mac (qt embedded in panel using QMacNativeWidget) , QLineEdit and other components do not seem to receive focus, nor are processing keyboard events. I cannot type into the text boxes or navigate through tree widget.

From Qt forums, seems like it is a known issue. Has anybody faced this issue, found a solution for this?

Qt: 4.8.6

OS: Mac os maveric

Illustrator: CC

This topic has been closed for replies.

3 replies

user8013581
Inspiring
March 6, 2019

bunny351​ was this your final solution? It doesn't work at all on my side. Although the problem on my side might be a bit different, as it does work sometimes. This is my thread, if anyone of anyone of you has a suggestion it'd be great:macOS Qt QLineEdit/QTextBox Focus Issue

Participant
December 3, 2014

There is a crude workaround that seems to work for me.

I subclass QLineEdit and override QWidget::macEvent for detecting mouse events. On a button press I activate

the window and set the focus manually:

#include <Carbon/Carbon.h>

bool MyLineEdit::macEvent ( EventHandlerCallRef caller, EventRef event )
{
 if(GetEventClass(event) == kEventClassMouse) {
   if(GetEventKind(event) == kEventMouseDown) {
      activateWindow();
      setFocus(Qt::OtherFocusReason);
    }
  }
  return false;
}

I admit that this is not a perfect solution, but at least it gives you /some/ sort of usable behaviour.

Inspiring
December 8, 2014

With Qt 5.4 it is better but there are still @some bugs

Inspiring
June 13, 2014

I didn't succeed to use QMacNativeWidget properly since Qt 4.7 and Qt didn't fix this bug. I used Objective-c++ instead.

Did you try with Qt 5.3 ?

Known Participant
June 27, 2014

I faced the same issue and dropped Qt. Objective C++ is much easier to use and I have not find a problem with it.

Strongly suggest using Objective C++ over Qt! It is not that difficult to switch, in the long run it is more flexible and the end .aip is 3 times smaller than with Qt.

panduvittala
Inspiring
July 3, 2014

Thanks for the suggestion, but we develop plugin on both mac and windows - the main reason to use Qt. We do not want to get into managing different code for platform specific native UI and having to fix bugs in 2 places. Apart from this keyboard event/focus issue (that too on UI embedded in panel only), everything else is working smoothly. Now if I find a solution for this focus issue, nothing like it.