[Interest] Questions about QGraphicsWidget

Bo Thorsen bo at fioniasoftware.dk
Wed Aug 8 09:53:10 CEST 2012


Den 07-08-2012 18:59, Bill Crocker skrev:
> On 08/07/2012 12:36 PM, BRM wrote:
>> I'm working on a QGraphicsWidget version of something I already have a QWidget version of; namely because I need to add some features where I need to overlay items, lines, and text in a way that QWidget does not support
>
> You can also overlay your existing widget with another widget
> on which you draw arbitrary text and lines.
> Set the overlay widget as transparent to mouse events.

This was exactly what I was about to answer. Going to QGW is the wrong 
approach for this problem. Unless of course there are other reasons for 
doing it. But it sounds like the OP is only converting to QGW to do this 
one thing.

You can create any QWidget with the top widget as parent and call 
raise() to bring it to the front of the other widgets. That will give 
you an overlay widget inside the window.

For overlays, I usually do this:

     setAttribute(Qt::WA_TranslucentBackground);
     setFocusPolicy(Qt::NoFocus);

in the constructor.

Bo Thorsen,
Fionia Software.

-- 

Expert Qt and C++ developer for hire
Contact me if you need expert Qt help
http://www.fioniasoftware.dk



More information about the Interest mailing list