[Qt-interest] Render Widgets inside QGLWidget

Samuel Rødal sroedal at trolltech.com
Fri May 29 13:34:35 CEST 2009


Ollie wrote:
> Hi,
> 
> I'm using QGraphicsView with QGLWidget and QGraphicsScene to display
> widgets over an opengl scene. One of the widgets is a QDialog holding
> a QGraphicsView together with  QGraphicsScene and some QGraphicsItems
> (see minimal sample code below). With this setup I encounter two
> problems.
> 
> 1) When moving the QDialog widget, the QGraphicsItems inside the
> QDialog stay at there position and don't move. Though, when scaling
> the widget all QGraphicsItems do adapt there position...
> 
> 2) The mouse sensitive area of the QGraphicsItem inside the QDialog
> is not aligned with its graphical representation. One needs to click a
> couple of pixels below or next to the item to properly select it. Is
> Painter missing some translation operation when drawing the items ..?
> 
> Is there a better way to render Widgets over a QGLWidget?
> 
> Any pointers or suggestions are greatly received.
> 
> Thanks
> Ollie

Which Qt version and platform are you using? Your example works fine for 
me with Qt 4.5 on Linux. I think there were some bugs regarding embedded 
graphics views inside graphics views that were fixed in 4.5.

Also, setting a cache mode on the embedded widget might help:

QGraphicsItem *item = scene1->addWidget(&dialog);
item->setCacheMode(QGraphicsItem::ItemCoordinateCache);

Regards,
Samuel



More information about the Qt-interest-old mailing list