i have a widget that has 15 arrays of pointers to QLabels that is supposed to act as a terrain map for a simple game. each QLabel acts a as a space a player can occupy and the map is 15 x 15
mapWidget.h
{
public:
private:
void releaseSpace(int xLoc, int yLoc);
void occpuySpace(int xLoc, int yLoc);
};
class mapWidget: public QWidget
{
public:
mapWidget(QWidget * parent=0);
private:
QGridLayout * mapLayout;
QLabel * x0[15];
QLabel * x1[15];
QLabel * x2[15];
QLabel * x3[15];
QLabel * x4[15];
QLabel * x5[15];
QLabel * x6[15];
QLabel * x7[15];
QLabel * x8[15];
QLabel * x9[15];
QLabel * x10[15];
QLabel * x11[15];
QLabel * x12[15];
QLabel * x13[15];
QLabel * x14[15];
void releaseSpace(int xLoc, int yLoc);
void occpuySpace(int xLoc, int yLoc);
};
To copy to clipboard, switch view to plain text mode
i am adding it as a child widget to another widget frmCombat, which contains the combat options a user can have. mapWidget and frmCombat's constructors run with out errors and mapWidget is added to frmCombat.
{
mainLayout->setSpacing(0);
this->map = new mapWidget(this);
//add map widget to frmCombat
this->mainLayout->addWidget(map);
}
frmCombat::frmCombat(QWidget *parent) :QWidget(parent)
{
this->mainLayout = new QGridLayout(this);
mainLayout->setSpacing(0);
this->map = new mapWidget(this);
//add map widget to frmCombat
this->mainLayout->addWidget(map);
}
To copy to clipboard, switch view to plain text mode
however when i go and display frmCombat Mac OSX gives me a EXC_BAD_ACCESS error. is it because i am putting the QLabels in a array instead of individual QLabels?
using:
Mac OSX 10.5.8
QT 4.6
QTCreator 1.3.1
Bookmarks