qt - Get keypresses in QSplashScreen on OSX -


i trying keypresses qsplashscreen before main window opens. splash class inherits qsplashscreen , overrides keypressevent method.

the code below works on windows on osx keypresses not intercepted until main window opens.

is there workaround this?

this using qt 5.2.1, think issue in earlier (4.x) versions too.

splash.cpp:

...  void splash::keypressevent(qkeyevent *evt) {      std::cout << evt->text().tostdstring() << std::endl; } 

main.cpp:

...  void delay(float seconds) {      qtime dietime= qtime::currenttime().addsecs(seconds);      while( qtime::currenttime() < dietime )          qcoreapplication::processevents(qeventloop::allevents, 100); }  int main(int argc, char *argv[]) {      qapplication a(argc, argv);       splash *splash = new splash;      splash->setpixmap(qpixmap(":/images/splash_loading.png"));      splash->show();      splash->grabkeyboard();       // on osx no keypresses captured here, on windows keypresses captured      delay(5.f);       mainwindow w;      w.show();       // keypresses captured here on osx , windows      delay(5.f);       splash->releasekeyboard();      splash ->hide();       return a.exec(); } 

i worked around creating invisible window before creating splashscreen.

int main(int argc, char *argv[]) {     qapplication a(argc, argv);      // create dummy window keypresses on osx     qlabel v(0, qt::framelesswindowhint);     v.setminimumsize(qsize(0, 0));     v.move(0,0);     v.show();      splash *splash = new splash;     splash->setpixmap(qpixmap(":/images/splash_loading.png"));     splash->show();     splash->grabkeyboard();      // keypresses captured here     delay(5.f);      // hide dummy window before showing main 1     v.hide();     mainwindow w;     w.show();      ... 

Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -