PDA

View Full Version : Issue with createWindowContainer + SDL



Brkopac
31st October 2014, 19:37
Hi All,

I'm trying to embed an SDL_Window (SDL2) into a QT Application, my code snippet for doing it is the following:


auto window = QWindow::fromWinId((WId)Application::windowHandle( ));
window->resize(width, height);

SIEGE_ASSERT(window);

mRenderSurface = QWidget::createWindowContainer(window);
setCentralWidget(mRenderSurface);

Application::windowHandle() returns the correct window id, the above results in the following:

http://i.imgur.com/xnEXGtO.png

For some reason the window isn't be "implanted" correctly into the central widget of the QMainWindow. If I use the GUI to resize the window, the widget will snap to the correct place, everything becomes resizeable and everything starts to work correctly. Am I missing a step in the process here that automatically implants and resizes it? From what I can tell when I add the widget to the central widget, it doesn't seem to repaint anything. It is also NOT an option to use the SDL_CreateWindowFrom function without patching SDL itself, this functionality is supposed to be on its way.

Thanks, Brkopac

edit: Currently using Qt 5.3

seb.tvpaint
2nd October 2020, 13:12
Hello,
I know this post is quite old, but i'm facing the same problem. I have a qwidget which is used as a container for a qwindow. This widget is contained in another qwidget. When i resize the container, the window is rendered above all other widgets and isn't always at its right position.
Have you found any solution since ?

d_stranz
2nd October 2020, 16:23
Are you using a layout to hold the container widget inside of its parent widget?

I do not know if it will help, but you might try wrapping the container widget with another plain QWidget / QLayout, and then inserting that wrapper widget into the parent. Basically, insert an additional layer that contains a layout to manage what is inside it.

seb.tvpaint
5th October 2020, 10:14
Hi,
Thanks for your answer :)

My widget is not hold in a layout. Its position is relative to the parent as i need to rotate it / scale it (it's a widget used to make drawing operations).
One thing that could help me would be to get an image (with a QImage ? ) of what is displayed on the window (used to do some rendering with vulkan) and render it in my widget.
But i don't know if it's possible.

d_stranz
5th October 2020, 21:57
My widget is not hold in a layout.

Then I would bet money that the way you construct this widget and place it in the parent is the source of your problem.

Milo47
6th October 2020, 15:07
Did you use SDL_CreateWindowFrom();?

d_stranz
6th October 2020, 20:38
Did you use SDL_CreateWindowFrom();?

No, and I am not talking about this. It doesn't matter how you obtain the QWidget, whether you create it directly or get it via QWidget hosting a QWindow created to wrap an native window handle. I am pretty sure the problem is how you are placing the new QWidget inside the hierarchy of your parent widget, especially since you say you aren't using a layout.

But instead of letting me guess, how about showing all of the code where you create -and- parent the QWidget containing the SDL window?