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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - sb

Pages: 1 [2]
16
General / Re: [SOLVED] Using SMFL for drawing into a Qt Widget
« on: October 22, 2015, 10:30:31 pm »
  /
\/

17
General / Re: [SOLVED] Using SMFL for drawing into a Qt Widget
« on: October 22, 2015, 12:34:29 pm »
I haven't used markdown before, so I hope this is okay. Feel free to change anything you want and thank you for posting. I know far too less about Qt and SFML to write such a tutorial from scratch.

Integrating SFML 2.3.2 to a Qt 5.5.1 interface
==============================================

How it worked in SFML 1.6
-------------------------

[A description of this.](http://www.sfml-dev.org/tutorials/1.6/graphics-qt.php)

Making it work in SFML 2.3.2
----------------------------

### Changed methods

The methods *Create* and *Display* were changed to lower-case in newer versions of SFML. Hence these changes must be applied to the code in the tutorial linked above. However, it seems like QWidget does also provide the method *create*, thus we have to be more precise and write *sf::create*. According to [this post](http://en.sfml-dev.org/forums/index.php?topic=13851.msg97124#msg97124), the argument in the *create*-statement should be cast to *sf::WindowHandle*, so the line with the *create*-statement ultimately becomes

*sf::RenderWindow::create((sf::WindowHandle) winId());* .

### Virtual methods
 
The derived class *QSFMLCanvas* inherits some virtual methods which have to be implemented. Adding

*QSFMLCanvas::~QSFMLCanvas() {}
void QSFMLCanvas::OnInit() {}
void QSFMLCanvas::OnUpdate() {}*

to the class definition should do it. (I think QSFMLCanvas is supposed to be virtual, so it might be better to declare those as virtual instead of dummy-implementing them.)

Everything should be working now.

### Resizing

When *QWidget::resize()* is called, the RenderWindow does not match the QWidget anymore. A solution to this (but maybe not the best one) is to call *sf::RenderWindow::create((sf::WindowHandle) winId());* once again subsequently.

18
General / Re: [SOLVED] Using SMFL for drawing into a Qt Widget
« on: October 21, 2015, 08:16:45 pm »
Yes.

19
General / Re: [SOLVED] Using SMFL for drawing into a Qt Widget
« on: October 21, 2015, 07:12:28 pm »
Is there a way of posting in the wiki without registering on GitHub?

20
General / Re: Using SMFL for drawing into a Qt Widget
« on: October 20, 2015, 02:18:48 pm »
Okay, it seems like I could fix it by implementing stubs for the virtual methods. Anyway, I suggest updating the tutorial I linked to in my post.

21
General / Re: Using SMFL for drawing into a Qt Widget
« on: October 20, 2015, 01:05:39 pm »
After finding the Post http://en.sfml-dev.org/forums/index.php?topic=13851.msg97124 I changed

create(winId());

to

sf::RenderWindow::create((sf::WindowHandle)winId());
 

and hence the ambiguity is gone. However, when building it now tells

undefined reference to to `vtable for QSMFLCanvas'
,

referencing line

myInitialized (false)

of

#include "qsmflcanvas.h"

QSFMLCanvas::QSFMLCanvas(QWidget* Parent, const QPoint& Position, const QSize& Size, unsigned int FrameTime) :
QWidget       (Parent),
myInitialized (false)
{

in the implementation of QSMFLCanvas as provided in http://www.sfml-dev.org/tutorials/1.6/graphics-qt.php .

Any ideas on this? The file qsmflcanvas.o seems to be built.

22
General / [SOLVED] Using SMFL for drawing into a Qt Widget
« on: October 19, 2015, 03:50:57 pm »
Hey there.

So I'm about to write an application using Qt Widgets and want to draw using SMFL 2.3.2. I'v stumbled upon

http://www.sfml-dev.org/tutorials/1.6/graphics-qt.php

but it seems to be a bit outdated. Apparently, the functions Create() and Display() were changed to lower-case. So after adjusting this, the compiler (MinGW) says that the reference to "create" is ambiguous, referencing the line "create(winId());" inside the function void QSFMLCanvas::showEvent(QShowEvent*).

I haven't used Qt before and only tried very basic things with SMFL, hence I do not know how to handle this.

I would be very grateful if someone could help me with this so I can actually begin with what I have in mind.

Pages: 1 [2]
anything