Results 1 to 4 of 4

Thread: Embedding SDL as a Widget

  1. #1
    Join Date
    Dec 2014
    Posts
    2
    Qt products
    Qt5
    Platforms
    MacOS X

    Default Embedding SDL as a Widget

    For a while I've been using SDL to write my 3D engine,and have recently been implementing an editor that can export an optimized format for the type of engine Im building. Right now the editor is fairly simple, objects can just be moved around and their textures and models can be changed. As of right now, I'm using SDL with OpenGL to render everything, but I want to use Qt for the GUI part of the editor, that way it looks native on every platform. I've got it working great so far, I'm running a QApplication inside of the SDL application, so it basically just opens 2 windows, one that uses SDL and OpenGL, and the other using Qt. Doing a bit of research, I've found that you can manually update a QApplication, which totally removes any threading problems, and everything works. Just in case you're having a hard time visualizing this, heres a picture:

    prbjc.jpg

    What my goal is to merge these windows into one, because on smaller screens (like my laptop's) it makes it really hard to keep track of all the different windows that I would eventually have. I know theres a way to render to Qt with OpenGL, but can this be integrated with SDL? Am I going to need to move away from using an SDL window and use a QT one if the editor is enabled? Just to clarify, when the engine isn't in editor mode, it won't use and Qt, just SDL, so optimally I wouldn't need to do this.

    Thanks

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Embedding SDL as a Widget

    If you can get a window handle for the SDL window, then you should be able to wrap it in a QWindow using QWindow::fromWinId().
    This should then be embedable with QWidget::createWindowContainer().

    Cheers,
    _

  3. #3
    Join Date
    Dec 2014
    Posts
    2
    Qt products
    Qt5
    Platforms
    MacOS X

    Default Re: Embedding SDL as a Widget

    Quote Originally Posted by anda_skoa View Post
    If you can get a window handle for the SDL window, then you should be able to wrap it in a QWindow using QWindow::fromWinId().
    This should then be embedable with QWidget::createWindowContainer().

    Cheers,
    _
    Doesn't this function only work on Windows though? I want to use it for Mac and Linux as well. (The docs say nothing about it)

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Embedding SDL as a Widget

    I did a quick search in the Qt sources and it appears that "ForeignWindows" are supported by the platform modules Android, Windows and XCB.

    Might indeed not work on OS X.

    You might have to look into integration the OpenGL rendering more directly.

    E.g. https://www.youtube.com/watch?v=BfIaTccy6HQ

    Cheers,
    _

Similar Threads

  1. Replies: 0
    Last Post: 19th September 2011, 16:10
  2. graphicsView and widget embedding
    By wagmare in forum Qt Programming
    Replies: 1
    Last Post: 17th July 2009, 16:14
  3. embedding X11
    By afflictedd2 in forum Qt Programming
    Replies: 5
    Last Post: 13th February 2009, 08:38
  4. Replies: 0
    Last Post: 4th February 2009, 14:46
  5. Embedding
    By shrikarcse in forum Newbie
    Replies: 1
    Last Post: 27th March 2006, 19:06

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
  •  
Qt is a trademark of The Qt Company.