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

Author Topic: troubles with Qt integration support on OS X  (Read 10394 times)

0 Members and 3 Guests are viewing this topic.

denismr

  • Newbie
  • *
  • Posts: 13
    • View Profile
troubles with Qt integration support on OS X
« on: August 25, 2011, 04:52:01 am »
Hi.

I'm a new user of both SFML and Qt and I had some troubles when I tried to make their integration.

I'm using Qt 4.7.4 and SFML 1.6.

I got the code of SFMLCanvas in the tutorial page (http://www.sfml-dev.org/tutorials/1.6/sources/QSFMLCanvas.hpp) and I have noticed that it's necessary to modify showEvent method, exchanging the line "Create(winId());" for "create();"

The OnUpdate method is being called, but it doesn't draw anything and doesn't even fill the canvas with the clear color.

Code: [Select]
void QAnimationPlayer::OnUpdate() {
    Clear(sf::Color(0, 255, 0, 255));
    sf::Shape line = sf::Shape::Line(sf::Vector2f(0,0),sf::Vector2f(200,200),20.f,sf::Color(255,0,255));
    Draw(line);
    std::cout << "I'm here\n";
    std::flush(std::cout);
}


Is qt integration on Mac OS X unsupported?

Sorry me for orthographic mistakes. English isn't my native language.
Thank you.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
troubles with Qt integration support on OS X
« Reply #1 on: August 25, 2011, 08:59:53 am »
Quote
exchanging the line "Create(winId());" for "create();"

This breaks the code. You must call the Create function from sf::RenderWindow. But I don't know if this is supposed to work with SFML 1.6 on OS X. Maybe it was not implemented or not working well.
Laurent Gomila - SFML developer

denismr

  • Newbie
  • *
  • Posts: 13
    • View Profile
troubles with Qt integration support on OS X
« Reply #2 on: August 25, 2011, 12:53:16 pm »
I saw this comment in the code of wxWidget integration:

Code: [Select]
// Tested under Windows XP only (should work with X11
        // and other Windows versions - no idea about MacOS)



Does it mean that integrating SFML to a GUI on OS X is currently possible only under Cocoa (or under direct X11, since OS X supports X11 applications in a compatibility mode)?

I was planning to write a program compatible with Windows and Mac OS.

Thank you

Groogy

  • Hero Member
  • *****
  • Posts: 1469
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
troubles with Qt integration support on OS X
« Reply #3 on: August 25, 2011, 01:19:39 pm »
DirectX11 and X11 are two very different things. X11 is a window system för Unix systems.
Developer and Maker of rbSFML and Programmer at Paradox Development Studio

denismr

  • Newbie
  • *
  • Posts: 13
    • View Profile
troubles with Qt integration support on OS X
« Reply #4 on: August 25, 2011, 01:33:12 pm »
Quote from: "Groogy"
DirectX11 and X11 are two very different things. X11 is a window system för Unix systems.


I know it.

I just forgot to put a sad smile at the end of my last line ( Cocoa and X11 aren't functional to my objective).

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
troubles with Qt integration support on OS X
« Reply #5 on: August 25, 2011, 01:46:39 pm »
Only Ceylo knows if SFML 1.6 can work this way with Qt. I know he worked hard on it before 1.6 was released, but I don't remember if everything was ok.
Laurent Gomila - SFML developer

Silvah

  • Guest
troubles with Qt integration support on OS X
« Reply #6 on: August 25, 2011, 04:19:20 pm »
Quote from: "Groogy"
DirectX11 and X11 are two very different things. X11 is a window system för Unix systems.
Why not für? :lol:

For these who don't know Swedish or German: both Swedish "för" /føːr/ and German "für" /fyːɐ̯/ mean "for".

Ceylo

  • Hero Member
  • *****
  • Posts: 2325
    • View Profile
    • http://sfemovie.yalir.org/
    • Email
troubles with Qt integration support on OS X
« Reply #7 on: August 25, 2011, 04:22:08 pm »
SFML 1.6 does work with Qt as soon as you use the Cocoa version of Qt. But I don't know whether it works with the default samples.

I'll tell you if I can get it to work as soon as I've got Qt downloaded (should be within 45min).
Want to play movies in your SFML application? Check out sfeMovie!

Ceylo

  • Hero Member
  • *****
  • Posts: 2325
    • View Profile
    • http://sfemovie.yalir.org/
    • Email
troubles with Qt integration support on OS X
« Reply #8 on: August 25, 2011, 04:56:34 pm »
Ok, it doesn't seem to work out of the box.

First I had to replace the Qt includes with QtCore and QtGui so that the Qt headers can be found. Then... for some reason QSFMLCanvas::paintEvent(QPaintEvent*) doesn't get called. I don't exactly know why, but I remember that when I had wanted to use Qt, I had set up a timer function called every 1/60 sec to do the drawing stuff. Then it had worked. Fixing the reason why paintEvent() doesn't get called may also fix the problem.

You may also experience a crash when exiting your Qt application. If this occurs, I'll tell you what to do, it's just a one line fix because of the memory management of Qt conflicting with SFML's one.
Want to play movies in your SFML application? Check out sfeMovie!

denismr

  • Newbie
  • *
  • Posts: 13
    • View Profile
troubles with Qt integration support on OS X
« Reply #9 on: August 25, 2011, 06:37:46 pm »
@Ceylo

Thank you for the clarifications.
I'm going to try something in this sense tomorrow and then I post the results here.

denismr

  • Newbie
  • *
  • Posts: 13
    • View Profile
troubles with Qt integration support on OS X
« Reply #10 on: August 25, 2011, 08:47:24 pm »
I've read a little and I've discovered some interesting things.

Since an old version of Qt (I think that it's the 4.5) was released, Cocoa is the default for 64bit architectures.

The winId method returns different types depending on which API is currently being used.

For the old versions of Qt that use Carbon instead of Cocoa, the return value is a HIViewRef, and it's possible to recovery the WindowHandle (needed by Create) from it using the method HIViewGetWindow.

But this doesn't work when Qt is using Cocoa. In this case, winId returns a NSView and I still don't know how to recovery an WindowHandle from it.

I'll search more as soon as I have free time.

Ceylo

  • Hero Member
  • *****
  • Posts: 2325
    • View Profile
    • http://sfemovie.yalir.org/
    • Email
troubles with Qt integration support on OS X
« Reply #11 on: August 25, 2011, 08:58:47 pm »
The SFML 1.x port has been made so that you can import both NSWindow and NSView objects. Thus the id returned by winId() is fine. The point here is rather about OpenGL drawing : it does not happen.
Want to play movies in your SFML application? Check out sfeMovie!

denismr

  • Newbie
  • *
  • Posts: 13
    • View Profile
troubles with Qt integration support on OS X
« Reply #12 on: August 26, 2011, 03:56:10 am »
Quote from: "Ceylo"
The SFML 1.x port has been made so that you can import both NSWindow and NSView objects. Thus the id returned by winId() is fine. The point here is rather about OpenGL drawing : it does not happen.


That's kinda sad.

I actually plan to make an sprite animation editor (as a part of a complete tool set) for a friend of mine (we are working on a project in our (short) free time and he draws well).

I already made one editor in 2010, in Java, for turning a homework easier, but it's simpler than what I need by now and it would be perfect if I don't mix the languages. This is why I want to use Qt (my friend uses Windows and I use Mac OS X and Linux).


-- off topic
For curiosity, the homework (for OOP classes in the uni) was a short game. I (and another friend) put in it some graph theory, vectorial collision check, punctual physics and the editor was useful only for making one animation: the explosion. The hurry was so big that we didn't make the physics right (we skipped the conservation of energy, entrusting the visual physical effect to the friction, what didn't work well, but we were very out of time. At least the collision check worked out). There were other problems too. Until that time, we didn't have CG classes and we didn't apply affine transformations correctly for the coordinates manipulation. =p

That's a video:
http://www.4shared.com/video/G-HkFttX/filme.html?
-- on topic

Back to the topic: I don't know if I should spend time trying to fix it. I have absolutely no experience with Qt and I can say the very same about my experience with SFML.
I really would love to do it, but my schedule is unbelievably impracticable: algorithm programming contest (ICPC), a lot of classes (8:00am -> 7:00pm) , scientific initiation (technical reports)...
Is there any alternative for integrating the GUI that works on Mac and on Windows?

Thank you very much for helping me.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
troubles with Qt integration support on OS X
« Reply #13 on: August 26, 2011, 08:58:00 am »
Have you tried SFML 2? There's no point working on SFML 1.6, it's not maintained anymore and SFML 2 will be released in a few weeks.
Laurent Gomila - SFML developer

Ceylo

  • Hero Member
  • *****
  • Posts: 2325
    • View Profile
    • http://sfemovie.yalir.org/
    • Email
troubles with Qt integration support on OS X
« Reply #14 on: August 26, 2011, 11:58:15 am »
I don't understand why you said it's sad, the only point is that the drawing method doesn't get called.
Want to play movies in your SFML application? Check out sfeMovie!