Anyone using Ogre with Qt 4.5? [SOLVED]
- PolyVox
- OGRE Contributor
- Posts: 1316
- Joined: Tue Nov 21, 2006 11:28 am
- Location: Groningen, The Netherlands
- x 18
- Contact:
Anyone using Ogre with Qt 4.5? [SOLVED]
Hi guys,
Has anyone here sucessfully embedded an Ogre window into an application built with Qt 4.5? I'd heard my QtOgre framework had problems with it, and today I upgraded and saw the problem for myself. The image only appears in 'bands' which move up and down very quickly. Hence you do see the whole image, but there is a lot of flickering.
It occurs with all Qt graphics systems ('native', 'raster', and 'opengl') and with both Ogre's OpenGL and Direct3D rendersystems.
Actually the flickering does go away if I pass Ogre a 'parentWindowHandle' rather than an 'externalWindowHandle', but then the image is offset by a few hundred pixels. Does anyone know the conceptual difference between these flags?
I don't really know how to fix it, so I'll be reverting to Qt 4.4 unless anyone has any ideas...
Has anyone here sucessfully embedded an Ogre window into an application built with Qt 4.5? I'd heard my QtOgre framework had problems with it, and today I upgraded and saw the problem for myself. The image only appears in 'bands' which move up and down very quickly. Hence you do see the whole image, but there is a lot of flickering.
It occurs with all Qt graphics systems ('native', 'raster', and 'opengl') and with both Ogre's OpenGL and Direct3D rendersystems.
Actually the flickering does go away if I pass Ogre a 'parentWindowHandle' rather than an 'externalWindowHandle', but then the image is offset by a few hundred pixels. Does anyone know the conceptual difference between these flags?
I don't really know how to fix it, so I'll be reverting to Qt 4.4 unless anyone has any ideas...
Last edited by PolyVox on Mon Apr 06, 2009 7:03 pm, edited 1 time in total.
-
- Gnoblar
- Posts: 6
- Joined: Mon Jun 09, 2008 4:04 pm
- x 1
Re: Anyone using Ogre with Qt 4.5?
I have just fixed it now !
You have simply to override the paintEngine method on the OgreWidget and return 0.
On Windows works, if you can test on other platforms it is better.
Best,
Angelo
You have simply to override the paintEngine method on the OgreWidget and return 0.
Code: Select all
QPaintEngine *OgreWidget:: paintEngine() const
{
return 0;
}
Best,
Angelo
- nikki
- Old One
- Posts: 2730
- Joined: Sat Sep 17, 2005 10:08 am
- Location: San Francisco
- x 13
- Contact:
- PolyVox
- OGRE Contributor
- Posts: 1316
- Joined: Tue Nov 21, 2006 11:28 am
- Location: Groningen, The Netherlands
- x 18
- Contact:
Re: Anyone using Ogre with Qt 4.5?
Excellent work! I just tested it and it seems good. You just saved me a lot of pain - thanks a lot! I will add this fix to SVN.rtlpixy wrote:I have just fixed it now !
You have simply to override the paintEngine method on the OgreWidget and return 0.
-
- Gnoblar
- Posts: 24
- Joined: Wed Mar 28, 2007 10:47 am
Re: Anyone using Ogre with Qt 4.5? [SOLVED]
Hi,
Has anyone managed to make it work on a Mac ?? I had an application that worked with Qt 4.4.0 and I added the exact same fix to make it work with 4.5 (override paintEngine to make it return 0), but I have a blank widget on Mac... It works fine on Linux&Windows though.
I am using Qt 4.5.2 and Ogre 1.4.9. Any help will be more than welcome...
Has anyone managed to make it work on a Mac ?? I had an application that worked with Qt 4.4.0 and I added the exact same fix to make it work with 4.5 (override paintEngine to make it return 0), but I have a blank widget on Mac... It works fine on Linux&Windows though.
I am using Qt 4.5.2 and Ogre 1.4.9. Any help will be more than welcome...

- jacmoe
- OGRE Retired Moderator
- Posts: 20570
- Joined: Thu Jan 22, 2004 10:13 am
- Location: Denmark
- x 179
- Contact:
Re: Anyone using Ogre with Qt 4.5? [SOLVED]
qtOgitor runs on the Mac.
I am not sure if it does using Ogre 1.4.9, but it does using Ogre trunk and Qt 4.5.
I am not sure if it does using Ogre 1.4.9, but it does using Ogre trunk and Qt 4.5.

/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
-
- Gnoblar
- Posts: 24
- Joined: Wed Mar 28, 2007 10:47 am
Re: Anyone using Ogre with Qt 4.5? [SOLVED]
Ok, thanks ! I am going to try to compare our sources then. I'll post something here if I manage to make it work !
-
- Gnoblar
- Posts: 24
- Joined: Wed Mar 28, 2007 10:47 am
Re: Anyone using Ogre with Qt 4.5? [SOLVED]
Unfortunately QtOgitor is using Ogre >= 1.7. And I tried to compare our code, the widget initialization and painting are identical... Maybe I will try to upgrade my Ogre version, but I am quite afraid of the time I will spend on making it compile
.

- jacmoe
- OGRE Retired Moderator
- Posts: 20570
- Joined: Thu Jan 22, 2004 10:13 am
- Location: Denmark
- x 179
- Contact:
Re: Anyone using Ogre with Qt 4.5? [SOLVED]
I told you we were using trunk. 
I think it's definitely worth your while to upgrade.
Especially since Masterfalcon joined the team we should see much improved support for the Mac.

I think it's definitely worth your while to upgrade.
Especially since Masterfalcon joined the team we should see much improved support for the Mac.

/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
-
- Gnoblar
- Posts: 24
- Joined: Wed Mar 28, 2007 10:47 am
Re: Anyone using Ogre with Qt 4.5? [SOLVED]
Oups, sorry I read your post too quickly
.
I just passed Ogre from 1.4.3 to 1.6.3 (latest SDK released), but I still got the same problem : my widget that should display Ogre is all blank !!
I wasn't doing all the hiddenparam stuff at OgreWidget initialization (and the creation of another OgreRenderWindow), but even by doing so it does not work... I am quite stuck here, especially because I am a windows developper and don't know very well MacOSX

I just passed Ogre from 1.4.3 to 1.6.3 (latest SDK released), but I still got the same problem : my widget that should display Ogre is all blank !!

I wasn't doing all the hiddenparam stuff at OgreWidget initialization (and the creation of another OgreRenderWindow), but even by doing so it does not work... I am quite stuck here, especially because I am a windows developper and don't know very well MacOSX

- joew
- Greenskin
- Posts: 113
- Joined: Fri Nov 03, 2006 6:03 pm
Re: Anyone using Ogre with Qt 4.5? [SOLVED]
Try doing what Jacmoe said and grab the source from trunk, I am using it with Qt 4.5 on the mac and have no problems.
-
- Gnoblar
- Posts: 24
- Joined: Wed Mar 28, 2007 10:47 am
Re: Anyone using Ogre with Qt 4.5? [SOLVED]
Yes I don't see any other option at the moment. I am going to try to compare a little more thoroughly the way we wrote our OgreWidget class before that though.
I don't see why it will work with a more recent version of Ogre though, as it is a change in Qt that causes the regression... But I will test it anyway
I don't see why it will work with a more recent version of Ogre though, as it is a change in Qt that causes the regression... But I will test it anyway

-
- Gnoblar
- Posts: 24
- Joined: Wed Mar 28, 2007 10:47 am
Re: Anyone using Ogre with Qt 4.5? [SOLVED]
Unfortunately, I didn't manage to compile Ogre from the trunk... It seems like I am going to spend hours on it...
Is there anyone that could explain to me the code of Qt Ogitor ? Because I don't understand why you need to create a "hiddenparams" stuff, and initialize a second Ogre::RenderWindow with it. I tried to do that as well, but it does not change anything...
Is there anyone that could explain to me the code of Qt Ogitor ? Because I don't understand why you need to create a "hiddenparams" stuff, and initialize a second Ogre::RenderWindow with it. I tried to do that as well, but it does not change anything...
- jacmoe
- OGRE Retired Moderator
- Posts: 20570
- Joined: Thu Jan 22, 2004 10:13 am
- Location: Denmark
- x 179
- Contact:
Re: Anyone using Ogre with Qt 4.5? [SOLVED]
'hiddenParams' is used for the primary, hidden window. It passes the handle of the grand-parent window.
Do not worry about that.
Provided you've got the latest Ogre, that code should work. 
Do not worry about that.

Code: Select all
Ogre::NameValuePairList params;
params["externalWindowHandle"] = Ogre::StringConverter::toString((size_t) (this->winId()));
mWhateverRenderWindow = mWhateverOgreRoot->createRenderWindow( "WhateverRenderWindow",
this->width(),
this->height(),
false,
¶ms );

/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
-
- Gnoblar
- Posts: 24
- Joined: Wed Mar 28, 2007 10:47 am
Re: Anyone using Ogre with Qt 4.5? [SOLVED]
Hi,
Thanks for your answer
!
Is it a known problem that the latest Ogre is needed with Qt 4.5 ? My problem is the following : we are about to release a new version of a professional tool. And I don't really feel comfortable releasing something with Ogre trunk. I'd rather use an official SDK from a stable branch (1.4.x or 1.6.x)...
Sorry to be so painful...
Thanks for your answer

Is it a known problem that the latest Ogre is needed with Qt 4.5 ? My problem is the following : we are about to release a new version of a professional tool. And I don't really feel comfortable releasing something with Ogre trunk. I'd rather use an official SDK from a stable branch (1.4.x or 1.6.x)...
Sorry to be so painful...

- jacmoe
- OGRE Retired Moderator
- Posts: 20570
- Joined: Thu Jan 22, 2004 10:13 am
- Location: Denmark
- x 179
- Contact:
Re: Anyone using Ogre with Qt 4.5? [SOLVED]
The only thing I can think of is .. try and use parentWindowHandle instead.
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
-
- Gnoblar
- Posts: 24
- Joined: Wed Mar 28, 2007 10:47 am
Re: Anyone using Ogre with Qt 4.5? [SOLVED]
Hi,
Thanks for the suggestion ! I just tried to do so and something odd happens : my ogreWidget is still all blank. However, I have another floating QWidget (named after my renderwidget "View"). And this widget is correctly resized when I resize my ogrewidget. Quite strange actually. But I do see some Ogre rendering, which seems good !
The only other way I found to see something from Ogre was to set the "fullscreen" param to true when creating the renderwindow. What I see then is crazy, but I can distinguish some part from Ogre...
Well I don't really know what to do next, besides crying under my desk
Thanks for the suggestion ! I just tried to do so and something odd happens : my ogreWidget is still all blank. However, I have another floating QWidget (named after my renderwidget "View"). And this widget is correctly resized when I resize my ogrewidget. Quite strange actually. But I do see some Ogre rendering, which seems good !
The only other way I found to see something from Ogre was to set the "fullscreen" param to true when creating the renderwindow. What I see then is crazy, but I can distinguish some part from Ogre...
Well I don't really know what to do next, besides crying under my desk

-
- Gnoblar
- Posts: 24
- Joined: Wed Mar 28, 2007 10:47 am
Re: Anyone using Ogre with Qt 4.5? [SOLVED]
Hi,
I just solved my problem after crying for some months. I post the solution here, as it may save some lives of a future generation ^^.
My problem was that I initialized all the Ogre stuff too soon (before any QWidget was displayed), and it seems that the window handle returned by Qt was not valid yet. I now call the Ogre initialization when my mainwindow is about to be displayed for the first time, and it works... Thanks for all the help above !
I just solved my problem after crying for some months. I post the solution here, as it may save some lives of a future generation ^^.
My problem was that I initialized all the Ogre stuff too soon (before any QWidget was displayed), and it seems that the window handle returned by Qt was not valid yet. I now call the Ogre initialization when my mainwindow is about to be displayed for the first time, and it works... Thanks for all the help above !