January 21, 2011

jdoe jdoe
Lab Rat
2 posts

Capture and Transform Events to a hidden QWidget/QGraphicaslView/QGraphicsScene

 

I try to put widgets onto object-textures to have dialogs in a 3D-Scene.

I managed render QWidget, QGraphicsScene or QGraphicsView into QImage via QPainter and copy the image into my texture. Everything works fine:

  1. mQtDialog = new EmbeddedDialog;
  2. mQtScene = new QGraphicsScene();
  3. mQtScene->addWidget(mQtDialog);
  4. mQtView = new QGraphicsView(mQtScene);


for each 3drender loop:
  1. Texture tex;
  2. QImage image(tex->GetWidth(), tex->GetWidth(), QImage::Format_ARGB32);
  3. QPainter imagePainter(&image);
  4. mQtView->render(&imagePainter);
  5. const uchar *imgdata = image.bits();
  6. memcpy(tex.data, imgdata, tex->GetWidth() * tex->GetHeight() * 4);

But I found no way to address event handling. I can’t call the show() method, otherwise the real dialog will shown on my screen.

Any suggestions how, capture events, transform it into texture space, and finally pass it to the Widget, Scene or View?

Calculate the screencoordinates into texture 2D coordinates is not the issue ;-)

Jan

1 reply

January 23, 2011

Taamalus Taamalus
Lab Rat
61 posts

Not sure what ‘Texture’ is in this context. If it’s OpenGL, this link might help; or this is what I’m studying myself right now.
http://www.digitalfanatics.org/projects/qt_tutorial/chapter14.html
see chapter six and seven for a simple set up.

Also, if you could elaborate a little on what you are trying to show and which events need to take place, someone would be able to help. Right now, the way I understand your code, calling show() would be the first command required to ‘see’ anything, but you wrote it’s already visible.

 Signature 

... time waits for no one. - Henry

 
  ‹‹ How do QGraphicsView transforms work?      Psycho-Naut, Global Game Jam ››

You must log in to post a reply. Not a member yet? Register here!