balajiam 0 Newbie Poster

Howdy,

I am creating a GUI in QT 4.5.3.

I am having a problem trying to create a new subclass of QWidget. I already have several (3) other subclasses of QWidget, but when I attempt to add an additional one, the code does not compile.

Here is the newClass:

// gamePeice.H

#include <QWidget>
#include <QPainter>

class gamePeice : public QWidget
{
public:
	gamePeice( QWidget *parent = 0, Qt::WindowFlags f = 0 );

	void paintEvent(QPaintEvent *event);

// additional Functions...

};

//GamePeice.cpp

#include "GamePeice.h"

// Constructor for the main Window
gamePeice::gamePeice(QWidget *parent, Qt::WindowFlags f )
        : QWidget( parent, f )
{
	//resize(w ,h);

}

void gamePeice::paintEvent(QPaintEvent *event)
{
	QPainter painter(this);

	painter.setPen(QPen(Qt::black, 1));
	painter.drawEllipse(0, 0, 50, 50);
}

//additional function declarations

It seems simple enough, but it does not work.

Here is a working subclass of QWidget:

// GameWindow.H

#include <QWidget>
#include <QFont>
#include <QLabel>
#include <QPainter>
#include <QLCDNumber>
#include "GamePeice.h"
#include <vector>


using namespace std;
// The main window that shows up at start up

class gameScreen : public QWidget
{
public:
	gameScreen( QWidget *parent=0, Qt::WindowFlags f = 0  );

	void paintEvent(QPaintEvent *event);

	gamePeice *t;

	vector< vector <gamePeice> > *listOfPeices;

// additional members

//additional functions

};

// gameWindow.cpp
#include "gameWindow.h"

// Constructor for the main Window
gameScreen::gameScreen( QWidget *parent, Qt::WindowFlags f  )
        : QWidget( parent, f )
{
	setWindowTitle(tr("Now Playing Game"));

	listOfPeices = new vector< vector <gamePeice> > ;
	t = new gamePeice(this);

	for(int i = 0; i < 8; i++)
	{
		vector<gamePeice> temp;
		for(int j = 0; j <8; j++)
		{
			
			t->setGeometry(50 + 50*i, 50, 100 + 50*j, 100);
			temp.push_back(*t);
		}
		listOfPeices->push_back(temp);
	}

// additional operations
}
// additional declarations

I get this problem in both VS2008 and G++.

I have spent hours on this. Help!

-- Thanks in Advance,
balajiam

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.