[Interest] Creating a hover form over a QGraphicsView

Lisandro Damián Nicanor Pérez Meyer perezmeyer at gmail.com
Tue Feb 7 18:32:50 CET 2017


On martes, 7 de febrero de 2017 12:10:33 ART Lisandro Damián Nicanor Pérez 
Meyer wrote:
> On sábado, 4 de febrero de 2017 10:19:34 ART Ch'Gans wrote:
> > On 4 February 2017 at 07:55, Lisandro Damián Nicanor Pérez Meyer
> > 
> > <perezmeyer at gmail.com> wrote:
> > > Hi! I am creating a hover form over a QGraphicsView widget. For starters
> > > I
> > > used designer to create a QWidget with all the necessary hover form
> > > widgets in it. Then I created a grid layout, added the hover form to it
> > > and finally added it to the QGraphicsView widget. As I expected the
> > > hover
> > > form appears over the QGraphicsView.
> > > 
> > > As the application runs on a touchscreen I was asked to let the user
> > > scroll it using her fingers... The above approach doesn't allows that as
> > > all the events end up in the widget containing the hover form.
> > > 
> > > How could I achive a hover form over a QGraphicsView but letting the
> > > user
> > > scroll the QGView with her fingers?
> > 
> > Hi
> > 
> > I don't know what an "hover form" is supposed to be or do,
> 
> Think of it as "widgets over a QGraphicsView", statically placed.

Maybe another good word is "overlay".
 
> > but maybe
> > QWidget::setAttribute(Qt::WA_TransparentForMouseEvents) could help in
> > your case.
> 
> This indeed seems the right way to go, I'll try it. Thanks!!!

Well no, as my overlay has clickable buttons as child widgets. Moreover the 
propagation order is always parent to child, and as the hoverform/overlay is a 
child of the QGraphicsView instance it won't work.

I happen to find another (possibly non-elegant) way of achieving this:

- Using designer create a hover form / overlay as wished.
- Create an instance of the hover form *without a parent*.
- Set up the hover form's layout as the QGraphicsView layout, always keeping 
the hover form instance.
- Be sure to delete the hover form on the destructor ;-)

Kinds regards, Lisandro.

-- 
“I don’t think security can solve problems.
We need to teach greater respect.”
  Oslo Mayor Stang when asked whether Oslo needs greater security
  after the attacks in Norway, 07/2011.

Lisandro Damián Nicanor Pérez Meyer
http://perezmeyer.com.ar/
http://perezmeyer.blogspot.com/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20170207/527ea513/attachment.sig>


More information about the Interest mailing list