PDA

View Full Version : "Incomplete" Event class types [solved]



Live-Dimension
5th August 2010, 13:47
Hello all!

I'm having a serious problem with what seems to be all events. Whenever I use them I get an error "pointer to incomplete class type not allowed". This is compiled under Visual Studio 2010. I've gone up the entire event source code and as far as I can tell, everything is actually right. Since I don't really know what this error means It's difficult to track down. Derived classes from QWidget compile, link, and work fine. Trying to use any event kind from inside any file has the same issue, so I highly doubt its a coding error on my side, unless I'm missing an include or something.

Here is a code sample from QSFMLTileSheet.cpp


#include "QSFMLTileSheet.h"

void QSFMLTileSheet::mousePressEvent(QMouseEvent* evt) {
if ((evt->x() > 0) {
//execute code
}
}

Trying to use evt gives the error "pointer to incomplete class type not allowed". Here is the header chain to QWidget.

QSFMLTileSheet.h

#ifndef INC_QSFMLTILESHEET_H
#define INC_QSFMLTILESHEET_H

#include "QSFMLCanvas.h"
#include "TileSheet.h"

namespace Toolkit {
class QSFMLTileSheet : public QSFMLCanvas {
public:
QSFMLTileSheet(QWidget* Parent = 0, const QPoint& Position = QPoint(0,0), const QSize& Size = QSize(0,0), unsigned int FrameTime = 0, bool StretchResize = false);

TileSheet* GetTileSheet();
void SetTileSheet(TileSheet* TSheet);

unsigned int GetWidth();
unsigned int GetHeight();

void SetSelectable(bool Enable);
bool GetSelectable();

void SetGridDrawing(bool Enable);
bool GetGridDrawing();

void SetDrawMouseHover(bool Enable);
bool GetDrawMouseHover();

void SetSelectedTileID(unsigned int TileID);
unsigned int GetSelectedTileID();

unsigned int GetTileXCountFromID(unsigned int TileID);
unsigned int GetTileYCountFromID(unsigned int TileID);

unsigned int GetMouseHoverTileID();

protected:
void OnInit();
void OnUpdate();

void mousePressEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);

private:
TileSheet* tsheet;

sf::Sprite tsheetPreview;
bool gridNeedsUpdating;
bool drawTileGrid;
bool selectable;
bool drawMouseHover;
unsigned int selectedTileID;
};
}
#endif


QSFMLCanvas.h

#ifndef INC_QSFMLCANVAS_H
#define INC_QSFMLCANVAS_H

#include <SFML/Graphics.hpp>
#include <Qt/qwidget.h>
#include <Qt/qtimer.h>

namespace Toolkit {
class QSFMLCanvas : public QWidget, public sf::RenderWindow {
public:
QSFMLCanvas(QWidget* Parent, const QPoint& Position, const QSize& Size, unsigned int FrameTime = 0, bool StretchResize = false);
virtual ~QSFMLCanvas();

protected:
virtual void OnInit();
virtual void OnUpdate();
virtual QPaintEngine* paintEngine() const;
virtual void showEvent(QShowEvent*);
virtual void paintEvent(QPaintEvent*);

QTimer myTimer;
bool myInitialized;
};
}
#endif

I'm not sure where to go from here. I don't mind having to recompile Qt.

Any help is appreciated, Thanks.

Lykurg
5th August 2010, 13:52
I bet you haven't included the neede headers. Try to add
#include <QMouseEvent> and also better do not include the actuall header file qwidget.h. better also use
#include <QtGui/QWidget>
// or
#include <QWidget>

Live-Dimension
5th August 2010, 13:59
Actually, now that you mention it, I'm not so sure my include directory is set right, but it looks right.

QT Root Dir "C:\Qt\vs2010\"
QT Include dir (set in project settings): "C:\Qt\vs2010\include\"

I keep having oddities, for example, #include <QMouseEvent> doesn't link to anything. I did notice that file seems to be missing.


also better do not include the actuall header file qwidget.h. better also use

Yeah I know. Problem is that visual studio automatically does that, and I get tired with fighting with it.

edit: looks likes I'm meant to include all the directories inside /include/. ehh! Is this true? I use visual studio because creator drove me up the wall, but I'm still trying to figure out the right settings.

edit: Well, after adding all the dirs inside /include suddenly everything works a whole lot better. Thankyou for giving me the idea!