Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Qt + SFML: Blank widget?  (Read 8220 times)

0 Members and 2 Guests are viewing this topic.

Skomakar'n

  • Newbie
  • *
  • Posts: 25
    • View Profile
Qt + SFML: Blank widget?
« on: July 13, 2010, 08:33:52 pm »
I have managed to get a Qt window with an SFML view integrated into it compiling and booting up perfectly fine; the problem is that the widget which is supposed to hold the SFML render viewport is completely blank.

It does work to create the SFML window separately, as a window of its own. It will update, clear to the right colour and render the sprite that I have told it to draw, but when using the Create() member function with the inherited winId() function from QWidget as its argument, after having to do a reinterpret cast to sf::WindowHandle *, or otherwise it won't compile, the widget is left blank.

I can't figure out what's wrong. Please help.
I've put everything I have so far on Pastebin:

main.cpp
classes/SFML/Viewport.h
classes/SFML/Viewport.cpp
classes/GUI/MainWindow.h
classes/GUI/MainWindow.cpp

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Qt + SFML: Blank widget?
« Reply #1 on: July 14, 2010, 11:11:33 am »
Did you try first the Qt sample from the SFML SDK?
Laurent Gomila - SFML developer

Skomakar'n

  • Newbie
  • *
  • Posts: 25
    • View Profile
Qt + SFML: Blank widget?
« Reply #2 on: July 14, 2010, 01:04:03 pm »
Quote from: "Laurent"
Did you try first the Qt sample from the SFML SDK?

My code is based on that code. I'm not missing out on anything that's been done there.
I guess I could add that I'm on Mac OS X Snow Leopard.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Qt + SFML: Blank widget?
« Reply #3 on: July 14, 2010, 03:01:39 pm »
Which version of SFML do you use?
Laurent Gomila - SFML developer

Skomakar'n

  • Newbie
  • *
  • Posts: 25
    • View Profile
Qt + SFML: Blank widget?
« Reply #4 on: July 14, 2010, 03:08:14 pm »
Quote from: "Laurent"
Which version of SFML do you use?

SFML 1.6 and Qt 4.6.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Qt + SFML: Blank widget?
« Reply #5 on: July 14, 2010, 03:17:52 pm »
sf::WindowHandle is void*, so you should try to cast winId() into sf::WindowHandle, not sf::WindowHandle*.
Laurent Gomila - SFML developer

Skomakar'n

  • Newbie
  • *
  • Posts: 25
    • View Profile
Qt + SFML: Blank widget?
« Reply #6 on: July 14, 2010, 03:44:12 pm »
That doesn't make any difference (and it doesn't make any sense to me to cast to a non-pointer either).

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Qt + SFML: Blank widget?
« Reply #7 on: July 14, 2010, 06:31:47 pm »
Quote
That doesn't make any difference

Ok, then I can't help more, you should see with Ceylo (I don't know if he's aware of this topic). I know that he worked a lot in SFML 1.6 to make the Qt integration work better.

Quote
and it doesn't make any sense to me to cast to a non-pointer either

??
Quote from: "Laurent"
sf::WindowHandle is void*
Laurent Gomila - SFML developer

Skomakar'n

  • Newbie
  • *
  • Posts: 25
    • View Profile
Qt + SFML: Blank widget?
« Reply #8 on: July 14, 2010, 06:44:24 pm »
Quote from: "Laurent"
Quote
That doesn't make any difference

Ok, then I can't help more, you should see with Ceylo (I don't know if he's aware of this topic). I know that he worked a lot in SFML 1.6 to make the Qt integration work better.

All right. Thanks. I'll throw him a PM.

Quote from: "Laurent"
Quote
and it doesn't make any sense to me to cast to a non-pointer either

??
Quote from: "Laurent"
sf::WindowHandle is void*

Ah! Sorry. I misinterpreted.

Ceylo

  • Hero Member
  • *****
  • Posts: 2325
    • View Profile
    • http://sfemovie.yalir.org/
    • Email
Qt + SFML: Blank widget?
« Reply #9 on: July 14, 2010, 07:05:32 pm »
From what I remember, you cannot import Qt windows with SFML because OpenGL needs some specific window attributes. And these attributes are not used by Qt (and cannot be set after window creation).

Maybe you noticed a "invalid drawable" message in your console, and I believe that's why you can only see a blank widget.

Thus... the only thing you can do is separating the SFML window from the Qt stuff : make a SFML window for your drawing, and other windows for the Qt stuff.
Want to play movies in your SFML application? Check out sfeMovie!

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Qt + SFML: Blank widget?
« Reply #10 on: July 14, 2010, 07:07:37 pm »
Quote
From what I remember, you cannot import Qt windows with SFML

Wasn't it supposed to work in 1.6 after your last modifications?
Laurent Gomila - SFML developer

Ceylo

  • Hero Member
  • *****
  • Posts: 2325
    • View Profile
    • http://sfemovie.yalir.org/
    • Email
Qt + SFML: Blank widget?
« Reply #11 on: July 14, 2010, 07:11:24 pm »
Nah. With the 1.6 modifications, you can import a Cocoa window or a Cocoa view (widget). And the object returned by Qt is a Cocoa view. But I can't do anything if the parent Cocoa window hasn't been created with the correct attributes (which is the problem with Qt).
Want to play movies in your SFML application? Check out sfeMovie!

Skomakar'n

  • Newbie
  • *
  • Posts: 25
    • View Profile
Qt + SFML: Blank widget?
« Reply #12 on: July 14, 2010, 08:12:01 pm »
Quote from: "Ceylo"
Nah. With the 1.6 modifications, you can import a Cocoa window or a Cocoa view (widget). And the object returned by Qt is a Cocoa view. But I can't do anything if the parent Cocoa window hasn't been created with the correct attributes (which is the problem with Qt).

Do you know which attributes are correct?

Ceylo

  • Hero Member
  • *****
  • Posts: 2325
    • View Profile
    • http://sfemovie.yalir.org/
    • Email
Qt + SFML: Blank widget?
« Reply #13 on: July 14, 2010, 08:15:54 pm »
The window device creation must not be defered. This is done by passing "NO" as latest argument of -[NSWindow initWithContentRect:styleMask:backing:defer:].

Edit: see the NSWindow class documentation
Want to play movies in your SFML application? Check out sfeMovie!

Skomakar'n

  • Newbie
  • *
  • Posts: 25
    • View Profile
Qt + SFML: Blank widget?
« Reply #14 on: July 14, 2010, 08:18:20 pm »
Isn't that Objective-C stuff? I'm using C++.

 

anything