QWidget in memory. problem with events.
I'm creating 3d game, using Ogre3d.
I’m trying to use Qt libs if it's possible and don’t want to add any other dependencies, so i don’t wanna use GUI libs (like CEGUI), but I whant to use Qt GUI.
So i’m implementing “TextureWidget” – this is plane in 3d space with texture of any QWidget based object.
to get “image of widget” for texture i use QWidget::render(QImage); every 100ms (QTimer), after i push this QImage to Ogre3D::Materal/texture/whatever =)
1st problem i've got: any QWidget, created in memory is disabled by default. to enable it – need to call show() method. But I don’t need to show my widget – i want to have it in memory only.
my solution: i put my widget to QGraphicsScene, cuz method QGraphicsScene::addWidget(QWidget * wgt); automaticaly call wgt->show(); and widget becomes enabled.
next: so i'm getting texture, but it's on the plane 3d space, making coordinates recalculation for this plane-widget, so i have x/y coords for widget like in usual QMouseEvent->pos().x()/y()
2nd problem: now i have a problem to translate Mouse/KeyEvents to “memory-widget”. i try to postEvent directly to widget – no result. try postEvent to QGraphicsScene – no result.
Eddy last edited by
Moved to the game development subforum where all the gaming experts like to hang out ;)
But i'm not shure - this is gamedev question (how to translate/generate events)
Eddy last edited by
By moving it, there is still a topic in the other subforum that opens this one when clicking on it.
Maybe more response if you show us more of your code?
QMouseEvent * e = new QMouseEvent(QEvent::MouseMove,mTranslatedWidget->property("pt").toPoint(),Qt::NoButton,Qt::NoButton,Qt::NoModifier);
property("pt") contains QPoint with x/y coords like it's 2d widget on screen in (0,0) position
mTranslatedWidget is QWidget* (existing in memory, and in QGraphicsScene)
so nobody has any ideas?
may be it is other way to grab texture and keep widget in memory with events system?
or where possible to read about difference in widget states "in memory"/"on screen"?
giesbert last edited by
System events (what mouse and keyboard are typically) are send in a different way:
sendSpontanousEvent, which is an internal Qt method.
I'm not 100% sure, if that can be achieved the way you try to do it...