Re: [Interest] Getting QGraphicsView from within a mouse event

2020-06-16 Thread Nicholas Yue
Thanks Giuseppe,

  Got it working.

Cheers

On Mon, 15 Jun 2020 at 02:46, Giuseppe D'Angelo 
wrote:

> Il 15/06/20 03:26, Nicholas Yue ha scritto:
> > The return widget object does not have a viewport() method from looking
> > at the QWidget - docs 
> >
> > void AttributeItem::mousePressEvent(QGraphicsSceneMouseEvent* event)
> > {
> >  if (event->button()==Qt::LeftButton)
> >  {
> >  QWidget *w = event->widget();
> >  } else
> >  QGraphicsItem::mousePressEvent(event);
> > }
>
> Sorry, what I meant is the other way around: the widget returned *is*
> the viewport() of your QGraphicsView. (So, typically, getting the parent
> widget of that widget will give you QGV you're looking for.)
>
> HTH,
>
> --
> Giuseppe D'Angelo | giuseppe.dang...@kdab.com | Senior Software Engineer
> KDAB (France) S.A.S., a KDAB Group company
> Tel. France +33 (0)4 90 84 08 53, http://www.kdab.com
> KDAB - The Qt, C++ and OpenGL Experts
>
>

-- 
Nicholas Yue
Graphics - Arnold, Alembic, RenderMan, OpenGL, HDF5
Custom Dev - C++ porting, OSX, Linux, Windows
http://au.linkedin.com/in/nicholasyue
https://vimeo.com/channels/naiadtools
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] Getting QGraphicsView from within a mouse event

2020-06-15 Thread Giuseppe D'Angelo via Interest

Il 15/06/20 03:26, Nicholas Yue ha scritto:
The return widget object does not have a viewport() method from looking 
at the QWidget - docs 


void AttributeItem::mousePressEvent(QGraphicsSceneMouseEvent* event)
{
     if (event->button()==Qt::LeftButton)
     {
         QWidget *w = event->widget();
     } else
         QGraphicsItem::mousePressEvent(event);
}


Sorry, what I meant is the other way around: the widget returned *is* 
the viewport() of your QGraphicsView. (So, typically, getting the parent 
widget of that widget will give you QGV you're looking for.)


HTH,

--
Giuseppe D'Angelo | giuseppe.dang...@kdab.com | Senior Software Engineer
KDAB (France) S.A.S., a KDAB Group company
Tel. France +33 (0)4 90 84 08 53, http://www.kdab.com
KDAB - The Qt, C++ and OpenGL Experts



smime.p7s
Description: Firma crittografica S/MIME
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] Getting QGraphicsView from within a mouse event

2020-06-14 Thread Nicholas Yue
The return widget object does not have a viewport() method from looking at
the QWidget - docs 

void AttributeItem::mousePressEvent(QGraphicsSceneMouseEvent* event)
{
if (event->button()==Qt::LeftButton)
{
QWidget *w = event->widget();
} else
QGraphicsItem::mousePressEvent(event);
}

On Sun, 14 Jun 2020 at 17:22, Giuseppe D'Angelo via Interest <
interest@qt-project.org> wrote:

> Il 15/06/20 00:50, Nicholas Yue ha scritto:
> > Hi,
> >
> >I understand that a QGraphicsScene may be view by multiple
> QGraphicsView
> >
> >When handling a mouse event, what is the Qt way to find out from
> > which view the event was from ?
>
> If you're handling a QGraphicsSceneEvent of some sort, its widget() will
> give you the viewport() of the view where the event originated, IIRC.
>
> HTH,
> --
> Giuseppe D'Angelo | giuseppe.dang...@kdab.com | Senior Software Engineer
> KDAB (France) S.A.S., a KDAB Group company
> Tel. France +33 (0)4 90 84 08 53, http://www.kdab.com
> KDAB - The Qt, C++ and OpenGL Experts
>
> ___
> Interest mailing list
> Interest@qt-project.org
> https://lists.qt-project.org/listinfo/interest
>


-- 
Nicholas Yue
Graphics - Arnold, Alembic, RenderMan, OpenGL, HDF5
Custom Dev - C++ porting, OSX, Linux, Windows
http://au.linkedin.com/in/nicholasyue
https://vimeo.com/channels/naiadtools
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] Getting QGraphicsView from within a mouse event

2020-06-14 Thread Giuseppe D'Angelo via Interest

Il 15/06/20 00:50, Nicholas Yue ha scritto:

Hi,

   I understand that a QGraphicsScene may be view by multiple QGraphicsView

   When handling a mouse event, what is the Qt way to find out from 
which view the event was from ?


If you're handling a QGraphicsSceneEvent of some sort, its widget() will 
give you the viewport() of the view where the event originated, IIRC.


HTH,
--
Giuseppe D'Angelo | giuseppe.dang...@kdab.com | Senior Software Engineer
KDAB (France) S.A.S., a KDAB Group company
Tel. France +33 (0)4 90 84 08 53, http://www.kdab.com
KDAB - The Qt, C++ and OpenGL Experts



smime.p7s
Description: Firma crittografica S/MIME
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


[Interest] Getting QGraphicsView from within a mouse event

2020-06-14 Thread Nicholas Yue
Hi,

  I understand that a QGraphicsScene may be view by multiple QGraphicsView

  When handling a mouse event, what is the Qt way to find out from which
view the event was from ?

Cheers
-- 
Nicholas Yue
Graphics - Arnold, Alembic, RenderMan, OpenGL, HDF5
Custom Dev - C++ porting, OSX, Linux, Windows
http://au.linkedin.com/in/nicholasyue
https://vimeo.com/channels/naiadtools
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest