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

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

0 Members and 1 Guest are viewing this topic.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
troubles with Qt integration support on OS X
« Reply #15 on: August 26, 2011, 01:33:51 pm »
Quote
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.

Hmm, this is exactly what is done in the QSMLCanvas class. There's a timer which triggers the pain event (otherwise it's called only when the widget needs to be repainted -- which means never if nothing happens).
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 #16 on: August 26, 2011, 01:42:50 pm »
Yup, but for some reason the method doesn't get called even for the first draw, and I don't know why and I don't have time to spend on it now.
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 #17 on: August 26, 2011, 03:29:57 pm »
Quote from: "Laurent"
Quote
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.

Hmm, this is exactly what is done in the QSMLCanvas class. There's a timer which triggers the pain event (otherwise it's called only when the widget needs to be repainted -- which means never if nothing happens).



Exactly! The way to call the paintEvent method is calling repaint method, and nothing happens when I do it manually (and the QSFMLCanvas already does it with its timer).
And it's only possible to draw through this method (before someone says, the attribute WA_PaintOutsidePaintEvent isn't supported on Mac and Windows).

I still think that the problem is in how I'm using Create method.
The QSFMLCanvas like it's distributed doesn't even is compiled, and if that line is commented, the repaint works but (obviously) nothing is drawn.
(For compiling, I was naively casting the return value of winId and when I do so, the paintEvent isn't called).
I didn't find the method that gets an WindowHandle from a NSView yet. I'm going to google it and maybe the problem will be solved.

Ceylo

  • Hero Member
  • *****
  • Posts: 2325
    • View Profile
    • http://sfemovie.yalir.org/
    • Email
troubles with Qt integration support on OS X
« Reply #18 on: August 26, 2011, 03:48:41 pm »
Quote from: "denismr"
(For compiling, I was naively casting the return value of winId and when I do so, the paintEvent isn't called).

Casting a pointer to another kind of pointer is fine.

Quote from: "denismr"
I didn't find the method that gets an WindowHandle from a NSView yet. I'm going to google it and maybe the problem will be solved.

-[NSView window]

But this is an Objective-C method, not C++, thus you'd need to use Objective-C++ to be able to use both (and change the file name extension to .mm instead of .cpp).
Besides, as already said, SFML 1.6 for Mac DOES support importing NSView object, thus the above is useless. If import didn't work, you would get an error message.

PS: and drawing outside of the paint event, even if I can't tell whether it's safe, did work for me, without specifying any attribute.
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 #19 on: August 26, 2011, 03:58:38 pm »
Quote from: "Ceylo"
Quote from: "denismr"
(For compiling, I was naively casting the return value of winId and when I do so, the paintEvent isn't called).

Casting a pointer to another kind of pointer is fine.

Quote from: "denismr"
I didn't find the method that gets an WindowHandle from a NSView yet. I'm going to google it and maybe the problem will be solved.

-[NSView window]

But this is an Objective-C method, not C++, thus you'd need to use Objective-C++ to be able to use both (and change the file name extension to .mm instead of .cpp).
Besides, as already said, SFML 1.6 for Mac DOES support importing NSView object, thus the above is useless. If import didn't work, you would get an error message.

PS: and drawing outside of the paint event, even if I can't tell whether it's safe, did work for me, without specifying any attribute.


Please, how did you draw outside the paint event? Did you just call the SFML methods like Clear, Draw, etc?
I tried this and nothing happens =/ .

Ceylo

  • Hero Member
  • *****
  • Posts: 2325
    • View Profile
    • http://sfemovie.yalir.org/
    • Email
troubles with Qt integration support on OS X
« Reply #20 on: August 26, 2011, 04:04:41 pm »
http://www.sfml-dev.org/forum/viewtopic.php?p=37163#37163

I just called the paintEvent() method through a timer. I did not change the contents of the method.
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 #21 on: August 26, 2011, 04:06:40 pm »
Quote from: "Ceylo"
http://www.sfml-dev.org/forum/viewtopic.php?p=37163#37163

I just called the paintEvent() method through a timer. I did not change the contents of the method.


Did you passed null as parameter (QPaintEvent*), since it isn't used? I tried this as well (and it still doesn't work).

Edit:
when you did so, were you using qt 3.x?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
troubles with Qt integration support on OS X
« Reply #22 on: August 26, 2011, 04:09:53 pm »
Don't do that, Qt has a well defined system for painting, based on the paintEvent which is triggered automatically whenever needed and/or by a call to repaint() (or update(), I don't remember).

If the paintEvent is never triggered, make sure that you have a QApplication running (ie. an event loop -- QtGui cannot run without it).
Laurent Gomila - SFML developer

denismr

  • Newbie
  • *
  • Posts: 13
    • View Profile
troubles with Qt integration support on OS X
« Reply #23 on: August 26, 2011, 04:33:18 pm »
Quote from: "Laurent"
Don't do that, Qt has a well defined system for painting, based on the paintEvent which is triggered automatically whenever needed and/or by a call to repaint() (or update(), I don't remember).

If the paintEvent is never triggered, make sure that you have a QApplication running (ie. an event loop -- QtGui cannot run without it).


As I said in this post
http://www.sfml-dev.org/forum/viewtopic.php?p=37247#37247
paintEvent isn't called even when I manually call repaint() method and I'm sure that the QApplication is running.

Ceylo

  • Hero Member
  • *****
  • Posts: 2325
    • View Profile
    • http://sfemovie.yalir.org/
    • Email
troubles with Qt integration support on OS X
« Reply #24 on: August 26, 2011, 04:37:36 pm »
I agree with Laurent, it's better to find out why the method doesn't get called. I had done this timer thing because I needed a quick and working demo.
Want to play movies in your SFML application? Check out sfeMovie!

 

anything