Bonjour a tous,
Ceci etant mon premier post sur le forum je tiens a saluer toute la communaute !
Dans le cadre d'un projet, je dois realiser une application Qt qui contiendra une vue SFML, j'ai donc suivi tutoriaux, guides, et forums afin d'adapter le QSFMLCanvas (
http://www.sfml-dev.org/tutorials/1.6/graphics-qt-fr.php), mais depuis son ajout au projet, ces erreurs (et seulement celles-ci ) apparaissent :
moc_QSFMLCanvas.o:(.data.rel.ro._ZTV11QSFMLCanvas[_ZTV11QSFMLCanvas]+0x270): undefined reference to `non-virtual thunk to sf::RenderWindow::getSize() const'
moc_QSFMLCanvas.o:(.data.rel.ro._ZTV11QSFMLCanvas[_ZTV11QSFMLCanvas]+0x278): undefined reference to `non-virtual thunk to sf::RenderWindow::activate(bool)'
collect2: error: ld returned 1 exit status
Voici mon header :
#ifndef __QSFMLCANVAS_H__
#define __QSFMLCANVAS_H__
#include <SFML/Graphics.hpp>
#include <QtWidgets>
#include <QTimer>
class QSFMLCanvas : public QWidget, public sf::RenderWindow
{
Q_OBJECT
public :
QSFMLCanvas(QWidget* Parent, const QPoint& Position, const QSize& Size, unsigned int FrameTime = 0);
virtual ~QSFMLCanvas();
private :
virtual void onInit();
virtual void onUpdate();
virtual QPaintEngine* paintEngine() const;
virtual void showEvent(QShowEvent*);
virtual void paintEvent(QPaintEvent*);
QTimer myTimer;
bool myInitialized;
};
#endif
Et l'implementation :
#include "QSFMLCanvas.h"
// Platform-specific headers
#ifdef Q_WS_X11
#include <Qt/qx11info_x11.h>
#include <X11/Xlib.h>
#endif
QSFMLCanvas::QSFMLCanvas(QWidget* Parent, const QPoint& Position, const QSize& Size, unsigned int FrameTime) :
QWidget (Parent),
myInitialized (false)
{
setAttribute(Qt::WA_PaintOnScreen);
setAttribute(Qt::WA_OpaquePaintEvent);
setAttribute(Qt::WA_NoSystemBackground);
setFocusPolicy(Qt::StrongFocus);
move(Position);
resize(Size);
myTimer.setInterval(FrameTime);
}
QSFMLCanvas::~QSFMLCanvas()
{
}
void QSFMLCanvas::onInit()
{
}
void QSFMLCanvas::onUpdate()
{
}
QPaintEngine* QSFMLCanvas::paintEngine() const
{
return (0);
}
void QSFMLCanvas::showEvent(QShowEvent*)
{
if (!myInitialized)
{
#ifdef Q_WS_X11
XFlush(QX11Info::display());
#endif
RenderWindow::create(winId());
onInit();
connect(&myTimer, SIGNAL(timeout()), this, SLOT(repaint()));
myTimer.start();
myInitialized = true;
}
}
void QSFMLCanvas::paintEvent(QPaintEvent*)
{
onUpdate();
display();
}
Cela reste assez obscur sachant que les librairies semblent bien linkees. Un peu d'eclairage ne ferait pas de mal !
Merci d'avance pour votre aide,
Datinmar