Thanks Robert. It is working fine...
On the left mouse press I am showing a message using QMessagBox. But on the
middle mouse press was having pan and right mouse press was having zoom in
zoom out. How can I retain those functionalities. With this these
functionalities are gone.
void CSGraphicsView::mousePressEvent(QMouseEvent *e)
{
if(e->button()==Qt::LeftButton)
{
QMessageBox msg;
msg.setText("Mouse pressed");
msg.exec();
}
}
On Wed, May 8, 2013 at 3:59 PM, Robert Milharcic <
[email protected]> wrote:
> On 8.5.2013 7:04, Sujan Dasmahapatra wrote:
>
>> I am trying to implement a mouse press event with QT and OSG but unable
>> to do it. Pls help.
>>
>> Below is my ViewerWidget class which is derived from QWidget and
>> osg::CompositeViewer......In the constructor I got gView which is a
>> osg::GLWidget, I am trying override mousePressEvent but when I click
>> message not coming. What I am doing wrong pls help..
>>
>> [snip]
>>
>>
>> osg::Camera* ViewerWidget::createCamera( int x, int y, int w, int h,
>> const std::string& name, bool windowDecoration )
>> {
>> osg::DisplaySettings* ds = osg::DisplaySettings::**
>> instance().get();
>> osg::ref_ptr<osg::**GraphicsContext::Traits> traits = new
>> osg::GraphicsContext::Traits;
>> traits->windowName = name;
>> traits->windowDecoration = windowDecoration;
>> traits->x = x;
>> traits->y = y;
>> traits->width = w;
>> traits->height = h;
>> traits->doubleBuffer = true;
>> traits->alpha = ds->getMinimumNumAlphaBits();
>> traits->stencil = ds->getMinimumNumStencilBits()**;
>> traits->sampleBuffers = ds->getMultiSamples();
>> traits->samples = ds->getNumMultiSamples();
>> osg::ref_ptr<osg::Camera> camera = new osg::Camera;
>> camera->setGraphicsContext( new
>> osgQt::GraphicsWindowQt(**traits.get())
>> );
>> camera->setClearColor( osg::Vec4(0.2, 0.2, 0.6, 1.0) );
>> camera->setViewport( new osg::Viewport(0, 0, traits->width,
>> traits->height) );
>> camera->**setProjectionMatrixAsPerspecti**ve(
>> 30.0f, static_cast<double>(traits->**
>> width)/static_cast<double>(**traits->height), 1.0f, 10000.0f );
>> return camera.release();
>> }
>>
>> I don't know why this code didn't crash, I think it should. Anyway, you
> should create an instance of the CSGraphicsView somewhere within
> createCamera:
>
> CSGraphicsView* gView = new CSGraphicsView;
> gView->setGeometry(x, y, w, h);
> traits->inheritedWindowData = new osgQt::GraphicsWindowQt::**WindowData(
> gView );
>
> ...
> or you can pass an instance of the CSGraphicsView to the
> osgQt::GraphicsWindowQt constructor.
>
>
> Robert Milharcic
> ______________________________**_________________
> osg-users mailing list
> osg-users@lists.**openscenegraph.org <[email protected]>
> http://lists.openscenegraph.**org/listinfo.cgi/osg-users-**
> openscenegraph.org<http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org>
>
--
Thanks & Regards
Sujan
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org