Results 1 to 7 of 7

Thread: Issue with createWindowContainer + SDL

  1. #1

    Default Issue with createWindowContainer + SDL

    Hi All,

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

    Qt Code:
    1. auto window = QWindow::fromWinId((WId)Application::windowHandle());
    2. window->resize(width, height);
    3.  
    4. SIEGE_ASSERT(window);
    5.  
    6. mRenderSurface = QWidget::createWindowContainer(window);
    7. setCentralWidget(mRenderSurface);
    To copy to clipboard, switch view to plain text mode 

    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

  2. #2

    Default Re: Issue with createWindowContainer + SDL

    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 ?

  3. #3
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    4,720
    Thanks
    259
    Thanked 760 Times in 750 Posts
    Qt products
    Qt5
    Platforms
    Windows Android

    Default Re: Issue with createWindowContainer + SDL

    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.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  4. #4

    Default Re: Issue with createWindowContainer + SDL

    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.
    Last edited by seb.tvpaint; 5th October 2020 at 14:11.

  5. #5
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    4,720
    Thanks
    259
    Thanked 760 Times in 750 Posts
    Qt products
    Qt5
    Platforms
    Windows Android

    Default Re: Issue with createWindowContainer + SDL

    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.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  6. #6
    Join Date
    Oct 2020
    Posts
    7
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Issue with createWindowContainer + SDL

    Did you use SDL_CreateWindowFrom();?

  7. #7
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    4,720
    Thanks
    259
    Thanked 760 Times in 750 Posts
    Qt products
    Qt5
    Platforms
    Windows Android

    Default Re: Issue with createWindowContainer + SDL

    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?
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. VNC Issue!
    By sanujas in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 24th October 2013, 08:22
  2. QWebView,QWidget,createWindowContainer,QWindow
    By PstdEr in forum Qt Programming
    Replies: 0
    Last Post: 9th October 2013, 08:44
  3. Error in CreateWindowContainer in Qt5.1.0
    By alizadeh91 in forum Qt Programming
    Replies: 12
    Last Post: 17th September 2013, 20:15
  4. Qt 5.0.1 Issue
    By kiboi in forum Qt-based Software
    Replies: 0
    Last Post: 22nd March 2013, 06:22
  5. Qt 4.7.1 VNC issue?
    By djstava in forum Newbie
    Replies: 0
    Last Post: 14th March 2011, 04:34

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.