So here's some new info, maybe someone will have any ideas about my problem. 
The problem is, again, when I press any keyboard key, all of my Qt widgets one 
by one move to certain point of the screen and freeze there, not working 
anymore. I'm trying to fight it with filtering keyboard events. So,
1) I've tried to add Qt event filter like this:

Code:

class myEventFilter: public QObject
{
  public:
  myEventFilter():QObject()
  {};
  ~myEventFilter(){};

  bool eventFilter(QObject* object,QEvent* event)
  {
      //for all events from keyboard, do nothing
      if (event->type() == QEvent::KeyPress || event->type() == 
QEvent::KeyRelease || event->type() == QEvent::ShortcutOverride) 
          {
                  std::cout<<"Filtered keyboard event\n";
          return true;
      } 
          else 
          {
        // for other, do as usual (standard event processing)
        return QObject::eventFilter(object, event);
      }
  };  
};




Code:

QApplication app(argc1, argv1);
app.installEventFilter(new myEventFilter());



It DOES NOT filter first few clicks, which actually screw up my interface, then 
starts to work: First I press a key few times, my interface is being completely 
screwed, and then on like 2nd-4th press it starts to output "Filtered keyboard 
event".
I thought it would catch the keypresses and not let them fail Qt widgets.

2) I've tried to install osgGA event handler like this:

Code:

class KeyboardEventHandler : public osgGA::GUIEventHandler 
    { 
      bool isImageCaptured; 
    public: 
      KeyboardEventHandler(): osgGA::GUIEventHandler() 
      { 
         isImageCaptured=false; 
      } 
       virtual bool handle(const osgGA::GUIEventAdapter& 
ea,osgGA::GUIActionAdapter&); 
        
      bool getImageCapFlag() 
      { 
         return isImageCaptured; 
      } 
    }; 
bool KeyboardEventHandler::handle(const osgGA::GUIEventAdapter& 
ea,osgGA::GUIActionAdapter& aa) 
     { 
        std::cout<<"In Event Handler"<<std::endl; 
       switch(ea.getEventType()) 
       { 
       case(osgGA::GUIEventAdapter::KEYDOWN): 
          { 
          std::cout<<"Event handled "<<std::endl; 
          return false; 
          } 
       default: 
          return false; 
       } 
    }




Code:

viewer.addEventHandler(new KeyboardEventHandler());



this one DOES output "Event handled" at every keypress, though it still has no 
effect on my problem. 

I'm stuck with this problem for very long time, maybe anyone has atleast any 
guesses what else can I try?

Thanks for your time.

P.S. Robert, my osgViewer certainly has some keyboard event handler, because on 
the S key, for example, it starts to show some statistics like it osgviewer 
example.

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=50669#50669





_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to