...this has become hugely frustrating. Thanks, GK- yeah, your example worked for me, too. I tinkered w/the HelloGL, as well, and it works. I even included the glwidget.h/.cpp file in my own application (i replaced coinWidget with the glWidget), turned on MouseTracking, at it works.
But nothing I do with coinWidget will work! I even tried commenting the moveMouseEvent feature in the mainWindow class, then editing the mainWindow eventFilter like so:
mainWindow::mainWindow()
{
coinWidget = new CoinWidget;
coinWidget->setMouseTracking(true);
coinWidget->installEventFilter(this);
.
.
.
{
if(event
->type
() == QEvent::MouseMove) {
qDebug("eventFilter: hello");
return QWidget::eventFilter(obj, event
);
}
else
{
return QWidget::eventFilter(obj, event
);
}
}
mainWindow::mainWindow()
{
coinWidget = new CoinWidget;
coinWidget->setMouseTracking(true);
coinWidget->installEventFilter(this);
.
.
.
bool mainWindow::eventFilter(QObject *obj, QEvent *event)
{
if(event->type() == QEvent::MouseMove)
{
qDebug("eventFilter: hello");
return QWidget::eventFilter(obj, event);
}
else
{
return QWidget::eventFilter(obj, event);
}
}
To copy to clipboard, switch view to plain text mode
but still only see "eventFilter: hello" if I click/drag the mouse button (on coinWidget). Other widgets with both installEventFilter() and setMouseTracking(true), however, work as expected.
So: the problem has to be my coinWidget class. This is a container widget for a coin3d scenegraph. Perhaps the SoQt widget embedded in the coinWidget is grabbing the moveMouseEvent even before Qt can? But I wouldn't think this could happen. Anyway, I'm posting the coinWidget code below. See anything???
//+++++++++++ coinwidget.h
#ifndef COINWIDGET_H
#define COINWIDGET_H
#include <QWidget>
#include <Inventor/Qt/SoQt.h>
class Model; // the class defining the coin3d geometry
{
Q_OBJECT
public:
~CoinWidget();
QSize minimumSizeHint
() const;
public slots:
void lyBG(int value);
void vuBG(int value);
void lyImgSL(int objID, int value);
void setComp(int value);
void zXagSL(int objID, int value);
void setRotAxis();
void vuSterSL();
void vuSterAcSL(int value);
void vuDrawAcSL(int value);
void vuOrthoSL();
void vuModLocSL();
signals:
protected:
// void mouseMoveEvent(QMouseEvent *event);
// above: deleted. Now only included in the mainWindow class
Model *model;
};
#endif
//+++++++++ coinwidget.cpp
#include <QtGui>
#include <QtCore>
#include <Inventor/Qt/SoQt.h>
#include <Inventor/Qt/viewers/SoQtExaminerViewer.h>
#include "coinwidget.h"
#include "model.h"
{
SoQt::init(this);
model = new Model(this);
model->setDefaultScene();
// this->setMouseTracking(true); // no longer included here;
// i do this in the mainWindow class
}
CoinWidget::~CoinWidget() { }
QSize CoinWidget
::minimumSizeHint() const { }
QSize CoinWidget
::sizeHint() const { }
void CoinWidget::vuBG(int value)
{
model->vuBG(value);
}
void CoinWidget::lyBG(int value)
{
model->lyBG(value);
}
void CoinWidget::setComp(int value)
{
model->setComp(value);
}
void CoinWidget::lyImgSL(int objID, int value)
{
model->lyImgSwi(objID, value);
}
void CoinWidget::zXagSL(int objID, int value)
{
model->set_zXag(objID, value);
}
void CoinWidget::setRotAxis()
{
model->setRotAxis();
}
void CoinWidget::vuSterSL()
{
model->vuSter();
}
void CoinWidget::vuSterAcSL(int value)
{
model->vuSterType(value);
}
void CoinWidget::vuDrawAcSL(int value)
{
model->vuDrawType(value);
}
void CoinWidget::vuOrthoSL()
{
model->vuOrtho();
}
void CoinWidget::vuModLocSL()
{
model->vuModLoc();
}
/*
void CoinWidget::mouseMoveEvent(QMouseEvent *event)
{
qDebug("CoinWidget:: %d %d", event->x(), event->y());
}
*/
//+++++++++++ coinwidget.h
#ifndef COINWIDGET_H
#define COINWIDGET_H
#include <QWidget>
#include <Inventor/Qt/SoQt.h>
class Model; // the class defining the coin3d geometry
class CoinWidget : public QWidget
{
Q_OBJECT
public:
CoinWidget(QWidget *parent = 0);
~CoinWidget();
QSize minimumSizeHint() const;
QSize sizeHint() const;
public slots:
void lyBG(int value);
void vuBG(int value);
void lyImgSL(int objID, int value);
void setComp(int value);
void zXagSL(int objID, int value);
void setRotAxis();
void vuSterSL();
void vuSterAcSL(int value);
void vuDrawAcSL(int value);
void vuOrthoSL();
void vuModLocSL();
signals:
protected:
// void mouseMoveEvent(QMouseEvent *event);
// above: deleted. Now only included in the mainWindow class
Model *model;
};
#endif
//+++++++++ coinwidget.cpp
#include <QtGui>
#include <QtCore>
#include <Inventor/Qt/SoQt.h>
#include <Inventor/Qt/viewers/SoQtExaminerViewer.h>
#include "coinwidget.h"
#include "model.h"
CoinWidget::CoinWidget(QWidget *parent) : QWidget(parent)
{
SoQt::init(this);
model = new Model(this);
model->setDefaultScene();
// this->setMouseTracking(true); // no longer included here;
// i do this in the mainWindow class
}
CoinWidget::~CoinWidget() { }
QSize CoinWidget::minimumSizeHint() const {
return QSize(200, 200);
}
QSize CoinWidget::sizeHint() const {
return QSize(400, 400);
}
void CoinWidget::vuBG(int value)
{
model->vuBG(value);
}
void CoinWidget::lyBG(int value)
{
model->lyBG(value);
}
void CoinWidget::setComp(int value)
{
model->setComp(value);
}
void CoinWidget::lyImgSL(int objID, int value)
{
model->lyImgSwi(objID, value);
}
void CoinWidget::zXagSL(int objID, int value)
{
model->set_zXag(objID, value);
}
void CoinWidget::setRotAxis()
{
model->setRotAxis();
}
void CoinWidget::vuSterSL()
{
model->vuSter();
}
void CoinWidget::vuSterAcSL(int value)
{
model->vuSterType(value);
}
void CoinWidget::vuDrawAcSL(int value)
{
model->vuDrawType(value);
}
void CoinWidget::vuOrthoSL()
{
model->vuOrtho();
}
void CoinWidget::vuModLocSL()
{
model->vuModLoc();
}
/*
void CoinWidget::mouseMoveEvent(QMouseEvent *event)
{
qDebug("CoinWidget:: %d %d", event->x(), event->y());
}
*/
To copy to clipboard, switch view to plain text mode
Bookmarks